addAllowedPointer method

  1. @override
void addAllowedPointer (PointerEvent 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(PointerEvent event) {
  // If the device has a maximum pressure of less than or equal to 1, it
  // doesn't have touch pressure sensing capabilities. Do not participate
  // in the gesture arena.
  if (!(event is PointerUpEvent) && event.pressureMax <= 1.0) {
    resolve(GestureDisposition.rejected);
  } else {
    startTrackingPointer(event.pointer, event.transform);
    if (_state == _ForceState.ready) {
      _state = _ForceState.possible;
      _lastPosition = OffsetPair.fromEventPosition(event);
    }
  }
}