onVerticalDragEnd method

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

Implementation

void onVerticalDragEnd(double velocity, double availableHeight) {
  if (!_state.isDragging) return;
  if (availableHeight <= 0) return;

  _state = _state.copyWith(isDragging: false);

  final phase = _state.phase;

  if (phase == OverlayPhase.fullscreen ||
      phase == OverlayPhase.expanding ||
      phase == OverlayPhase.collapsing ||
      _verticalIntent == _VerticalIntent.expand) {
    final shouldExpand = _resolveExpandSnap(
      _expandController.value,
      velocity,
    );
    if (shouldExpand) {
      _state = _state.copyWith(
        phase: OverlayPhase.expanding,
        isAnimating: true,
      );
      _expandController.animateTo(
        1.0,
        duration: _remainingDuration(
          _expandController.value,
          1.0,
          expandDuration,
        ),
        curve: expandCurve,
      );
    } else {
      _state = _state.copyWith(
        phase: OverlayPhase.collapsing,
        isAnimating: true,
      );
      _expandController.reverse(from: _expandController.value);
    }
  } else if (_verticalIntent == _VerticalIntent.dismiss ||
      phase == OverlayPhase.disappearing) {
    final shouldDismiss = _resolveDismissSnap(
      _overlayController.value,
      velocity,
    );
    if (shouldDismiss) {
      _state = _state.copyWith(
        phase: OverlayPhase.disappearing,
        isAnimating: true,
      );
      _overlayController.reverse(from: _overlayController.value);
    } else {
      _state = _state.copyWith(
        phase: OverlayPhase.appearing,
        isAnimating: true,
      );
      _overlayController.animateTo(
        1.0,
        duration: _remainingDuration(
          _overlayController.value,
          1.0,
          appearDuration,
        ),
        curve: appearCurve,
      );
    }
  }

  _verticalIntent = _VerticalIntent.none;
  notifyListeners();
}