detectDoubleTap method

  1. @protected
bool detectDoubleTap(
  1. PointerDownEvent details
)

Detects whether a PointerDownEvent is part of a double-tap gesture.

Returns true if two taps occur within the debounce duration.

Implementation

@protected
bool detectDoubleTap(PointerDownEvent details) {
  _activePointers.add(details.pointer);

  if (_activePointers.length > 1) {
    _doubleTapCountHelper = 0;
    _doubleTapDebounce.cancel();
    return false;
  }

  final tapPosition = details.position;

  if (_lastTapDownOffset != null &&
      (tapPosition - _lastTapDownOffset!).distance > _doubleTapSlop) {
    // Too far apart — reset
    _doubleTapCountHelper = 0;
  }

  _lastTapDownOffset = details.position;
  _doubleTapCountHelper++;
  _doubleTapDebounce(() {
    _doubleTapCountHelper = 0;
  });
  return _doubleTapCountHelper == 2;
}