end method

  1. @override
void end(
  1. DragEndDetails details
)
override

The pointer is no longer in contact with the screen.

The velocity at which the pointer was moving when it stopped contacting the screen is available in the details.

Implementation

@override
void end(DragEndDetails details) {
  assert(details.primaryVelocity != null);
  // We negate the velocity here because if the touch is moving downwards,
  // the scroll has to move upwards. It's the same reason that update()
  // above negates the delta before applying it to the scroll offset.
  double velocity = -details.primaryVelocity!;
  if (_reversed) {
    velocity = -velocity;
  }
  _lastDetails = details;

  if (_retainMomentum) {
    // Build momentum only if dragging in the same direction.
    final bool isFlingingInSameDirection = velocity.sign == carriedVelocity!.sign;
    // Build momentum only if the velocity of the last drag was not
    // substantially lower than the carried momentum.
    final bool isVelocityNotSubstantiallyLessThanCarriedMomentum =
      velocity.abs() > carriedVelocity!.abs() * momentumRetainVelocityThresholdFactor;
    if (isFlingingInSameDirection && isVelocityNotSubstantiallyLessThanCarriedMomentum) {
      velocity += carriedVelocity!;
    }
  }
  delegate.goBallistic(velocity);
}