onVerticalDragEnd method

void onVerticalDragEnd(
  1. double velocity,
  2. double availableHeight
)

Implementation

void onVerticalDragEnd(double velocity, double availableHeight) {
  if (availableHeight <= 0) return;
  final normalizedVelocity = -velocity / availableHeight;
  final progress = _animationController.value;

  _state = _state.copyWith(isDragging: false, velocity: normalizedVelocity);

  final shouldExpand = _resolveVerticalSnap(progress, velocity);

  if (shouldExpand) {
    _updatePhase(CardPhase.transitioningToFull);
    _animationController.animateTo(
      1.0,
      duration: _remainingDuration(progress, 1.0, expandDuration),
      curve: expandCurve,
    );
  } else {
    _updatePhase(CardPhase.transitioningToCard);
    _animationController.animateTo(
      0.0,
      duration: _remainingDuration(progress, 0.0, collapseDuration),
      curve: collapseCurve,
    );
  }
}