setState method
Animates the sheet to the specified state.
newState: The target state to animate to.duration: Custom duration for the animation (optional).curve: Custom curve for the animation (optional).
Default duration is calculated base on the distance between current and new state.
Implementation
void setState(StateType newState, {Duration? duration, Curve? curve}) {
final stateIndex = _extent.stateMapper.index(newState);
final newPosition =
_extent.behavior.statePosition(extent: _extent, state: stateIndex);
final distanceDuration = duration?.inMilliseconds ??
math.max((_extent.offset - newPosition).abs().round(), 150).toInt();
_startAnimation(
_extent.offset, newPosition, curve ?? mainCurve, distanceDuration);
}