handleEvent method

  1. @override
void handleEvent(
  1. PointerEvent event

Called when a pointer event is routed to this recognizer.

This will be called for every pointer event while the pointer is being tracked. Typically, this recognizer will start tracking the pointer in addAllowedPointer, which means that handleEvent will be called starting with the PointerDownEvent that was passed to addAllowedPointer.

See also:


void handleEvent(PointerEvent event) {
  if (event.pointer != _primaryPointer) {
  if (event is PointerMoveEvent) {
    // Receiving a [PointerMoveEvent], does not automatically mean the pointer
    // being tracked is doing a drag gesture. There is some drift that can happen
    // between the initial [PointerDownEvent] and subsequent [PointerMoveEvent]s.
    // Accessing [_pastSlopTolerance] lets us know if our tap has moved past the
    // acceptable tolerance. If the pointer does not move past this tolerance than
    // it is not considered a drag.
    // To be recognized as a drag, the [PointerMoveEvent] must also have moved
    // a sufficient global distance from the initial [PointerDownEvent] to be
    // accepted as a drag. This logic is handled in [_hasSufficientGlobalDistanceToAccept].
    // The recognizer will also detect the gesture as a drag when the pointer
    // has been accepted and it has moved past the [slopTolerance] but has not moved
    // a sufficient global distance from the initial position to be considered a drag.
    // In this case since the gesture cannot be a tap, it defaults to a drag.
    final double computedSlop = computeHitSlop(event.kind, gestureSettings);
    _pastSlopTolerance = _pastSlopTolerance || _getGlobalDistance(event, _initialPosition) > computedSlop;

    if (_dragState == _DragState.accepted) {
    } else if (_dragState == _DragState.possible) {
      if (_start == null) {
        // Only check for a drag if the start of a drag was not already identified.

      // This can occur when the recognizer is accepted before a [PointerMoveEvent] has been
      // received that moves the pointer a sufficient global distance to be considered a drag.
      if (_start != null) {
  } else if (event is PointerUpEvent) {
    if (_dragState == _DragState.possible) {
      // The drag has not been accepted before a [PointerUpEvent], therefore the recognizer
      // attempts to recognize a tap.
    } else if (_dragState == _DragState.accepted) {
  } else if (event is PointerCancelEvent) {
    _dragState = _DragState.ready;