considerFling method

  1. @override
DragEndDetails? considerFling(
  1. VelocityEstimate estimate,
  2. PointerDeviceKind kind
)
override

Determines if a gesture is a fling or not, and if so its effective velocity.

A fling calls its gesture end callback with a velocity, allowing the provider of the callback to respond by carrying the gesture forward with inertia, for example.

Implementation

@override
DragEndDetails? considerFling(VelocityEstimate estimate, PointerDeviceKind kind) {
  if (!isFlingGesture(estimate, kind)) {
    return null;
  }
  final double maxVelocity = maxFlingVelocity ?? kMaxFlingVelocity;
  final double dx = clampDouble(estimate.pixelsPerSecond.dx, -maxVelocity, maxVelocity);
  return DragEndDetails(
    velocity: Velocity(pixelsPerSecond: Offset(dx, 0)),
    primaryVelocity: dx,
    globalPosition: _lastPosition.global,
    localPosition: _lastPosition.local,
  );
}