settleDragBack method

  1. @protected
Future<void>? settleDragBack({
  1. required bool pops,
  2. required Offset velocity,
})

Completes once the route rests after the release, or is null if it does.

Implementation

@protected
Future<void>? settleDragBack({required bool pops, required Offset velocity}) {
  final controller = dragBackController;
  final width = _dragBackExtent.width;
  final speed = _releaseSpeedOf(width == 0 ? 0.0 : velocity.dx / width);
  final target = pops ? 0.0 : 1.0;
  if (pops && isCurrent) {
    navigator!.pop();
  }
  final goesPastRest = !pops || _dragBackOverdrag.value > 0;
  if (goesPastRest) {
    controller.stop();
    return _follower!
        .moveTo(
          Offset((1 - target) * width, 0),
          _releaseSpring,
          velocity: Offset(speed * width, 0),
          endsOnArrival: pops,
        )
        .then((_) {
          if (_follower != null) {
            controller.value = target;
          }
        });
  }
  if (!controller.isAnimating) {
    return null;
  }
  controller.animateBackWith(
    ArrivingSimulation(
      SpringSimulation(_releaseSpring, controller.value, target, -speed),
      end: target,
    ),
  );
  return whenStopped(controller);
}