collapse method

void collapse({
  1. Duration? duration,
  2. Curve? curve,
})

Collapse back to origin.

Implementation

void collapse({Duration? duration, Curve? curve}) {
  _isCollapsingIntent = true;
  _setState(_state.copyWith(phase: MorphPhase.collapsing, isDragging: false));

  final from = _animationController.value;
  if (from <= 0.0) {
    _isCollapsingIntent = false;
    _setState(
      _state.copyWith(phase: MorphPhase.collapsed, isDragging: false),
    );
    return;
  }

  final remaining = _remaining(from, 0.0, duration ?? _collapseDuration);
  _animationController.animateTo(
    0.0,
    duration: remaining,
    curve: curve ?? _collapseCurve,
  );
}