isFlingGesture method

bool isFlingGesture(
  1. VelocityEstimate estimate,
  2. PointerDeviceKind kind
)

Determines if a gesture is a fling or not based on 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

bool isFlingGesture(VelocityEstimate estimate, PointerDeviceKind kind) {
  final double minVelocity = minFlingVelocity ?? kMinFlingVelocity;
  final double minDistance = minFlingDistance ?? computeHitSlop(kind, gestureSettings);

  return ((_direction == DIRECTION_LEFT || _direction == DIRECTION_RIGHT) && (estimate.pixelsPerSecond.dx.abs() > minVelocity && estimate.offset.dx.abs() > minDistance)
  || (_direction == DIRECTION_UP || _direction == DIRECTION_DOWN) && (estimate.pixelsPerSecond.dy.abs() > minVelocity && estimate.offset.dy.abs() > minDistance));
}