addAllowedPointer method

  1. @override
void addAllowedPointer(
  1. PointerDownEvent event
)
override

Registers a new pointer that's been checked to be allowed by this gesture recognizer.

Subclasses of GestureRecognizer are supposed to override this method instead of addPointer because addPointer will be called for each pointer being added while addAllowedPointer is only called for pointers that are allowed by this recognizer.

Implementation

@override
void addAllowedPointer(PointerDownEvent event) {
  if (_firstTap != null) {
    if (!_firstTap!.isWithinGlobalTolerance(event, kDoubleTapSlop)) {
      // Ignore out-of-bounds second taps.
      return;
    } else if (!_firstTap!.hasElapsedMinTime() || !_firstTap!.hasSameButton(event)) {
      // Restart when the second tap is too close to the first (touch screens
      // often detect touches intermittently), or when buttons mismatch.
      _reset();
      return _trackTap(event);
    } else if (onDoubleTapDown != null) {
      final TapDownDetails details = TapDownDetails(
        globalPosition: event.position,
        localPosition: event.localPosition,
        kind: getKindForPointer(event.pointer),
      );
      invokeCallback<void>('onDoubleTapDown', () => onDoubleTapDown!(details));
    }
  }
  _trackTap(event);
}