didStopTrackingLastPointer method

  1. @override
void didStopTrackingLastPointer(
  1. int pointer
)
override

Called when the number of pointers this recognizer is tracking changes from one to zero.

The given pointer ID is the ID of the last pointer this recognizer was tracking.

Implementation

@override
void didStopTrackingLastPointer(int pointer) {
  switch (_dragState) {
    case _DragState.ready:
      _checkCancel();
      resolve(GestureDisposition.rejected);

    case _DragState.possible:
      if (_pastSlopTolerance) {
        // This means the pointer was not accepted as a tap.
        if (_wonArenaForPrimaryPointer) {
          // If the recognizer has already won the arena for the primary pointer being tracked
          // but the pointer has exceeded the tap tolerance, then the pointer is accepted as a
          // drag gesture.
          if (currentDown != null) {
            if (!_acceptedActivePointers.remove(pointer)) {
              resolvePointer(pointer, GestureDisposition.rejected);
            }
            _dragState = _DragState.accepted;
            _acceptDrag(currentDown!);
            _checkDragEnd();
          }
        } else {
          _checkCancel();
          resolve(GestureDisposition.rejected);
        }
      } else {
        // The pointer is accepted as a tap.
        if (currentUp != null) {
          _checkTapUp(currentUp!);
        }
      }

    case _DragState.accepted:
      // For the case when the pointer has been accepted as a drag.
      // Meaning [_checkTapDown] and [_checkDragStart] have already ran.
      _checkDragEnd();
  }

  _stopDeadlineTimer();
  _start = null;
  _dragState = _DragState.ready;
  _pastSlopTolerance = false;
}