MultiStateSheetController<StateType> constructor

MultiStateSheetController<StateType>({
  1. required SnappingBehavior behavior,
  2. required SheetStateMapper<StateType> stateMapper,
  3. StateType? initialState,
  4. double durationMultiplier = 1.0,
  5. double forceMultiplier = 1.25,
  6. Curve mainCurve = Curves.decelerate,
  7. Curve initialOpenCurve = Curves.easeOutExpo,
  8. bool resetContentScrollOnHiddenState = false,
})

Constructs a MultiStateSheetController with the specified snapping behavior and state mapper.

  • behavior: Defines the snapping behavior for the sheet.
  • stateMapper: Maps states to their indices and vice versa.
  • initialState: The initial state to which the sheet will snap on opening.
  • durationMultiplier: Adjusts the duration of animations default is 1.0.
  • mainCurve: The animation curve used to animate sheet's transition.
  • initialOpenCurve: The animation curve used to animate the initial opening animation of the sheet.
  • resetContentScrollOnHiddenState: If true, resets scroll position when the sheet is hidden.

Implementation

MultiStateSheetController({
  required SnappingBehavior behavior,
  required SheetStateMapper<StateType> stateMapper,

  /// The initial state that will be used to animate the sheet state when it opens.
  StateType? initialState,

  /// Changes the time that in animations will be executed. 1.0 is the default multiplier
  /// Change it to > 1.0 for speeding up the animation and < 1.0 for slowing it down.
  this.durationMultiplier = 1.0,

  /// Adjusts the force applied to velocity in snapping position calculations.
  ///
  /// - A value greater than `1.0` makes the sheet more anchored to the next position.
  /// - A value less than `1.0` makes the sheet less anchored to the next position
  ///  and more anchored to the previous position.
  this.forceMultiplier = 1.25,

  /// The animation curve used for the sheet's transition.
  ///
  /// Defaults to [Curves.decelerate].
  this.mainCurve = Curves.decelerate,

  /// The curve used for the initial opening animation of the sheet.
  ///
  /// Defaults to [Curves.easeOutExpo].
  this.initialOpenCurve = Curves.easeOutExpo,

  /// Defines if the content scroll should reset then sheet state is hidden.
  bool resetContentScrollOnHiddenState = false,
}) {
  _extent = MultiStateSheetExtent(
      behavior: behavior,
      stateMapper: stateMapper,
      initialState:
          initialState != null ? stateMapper.index(initialState) : 0,
      availablePixels: kStartOfTheViewport,
      durationMultiplier: durationMultiplier,
      onOffsetChanged: _notifyHeightChanged,
      onStateChanged:
          resetContentScrollOnHiddenState ? _resetScrollPosition : null,
      forceMultiplier: forceMultiplier);
}