handlePointerEvent method

void handlePointerEvent(
  1. PointerEvent event
)

Implementation

void handlePointerEvent(PointerEvent event) {
  if (!(event is PointerDownEvent ||
      event is PointerUpEvent ||
      event is PointerMoveEvent ||
      event is PointerCancelEvent)) {
    // Only basic Point events are handled, other event does nothing and returns directly such as hover and scroll.
    return;
  }

  // Stores the current TouchPoint to trigger the corresponding event.
  TouchPoint touchPoint = _toTouchPoint(event);

  _addPoint(touchPoint);

  if (event is PointerDownEvent) {
    _gatherEventsInPath();

    // Clear timer to prevent accidental clear target.
    _stopClearTargetTimer();

    // The current eventTarget state needs to be stored for use in the callback of GestureRecognizer.
    _target = _eventPath.isNotEmpty ? _eventPath.first : null;
    if (_target != null) {
      _bindEventTargetWithTouchPoint(touchPoint, _target!);
    }
  }

  _handleTouchPoint(touchPoint);

  // Make sure gesture event is dispatched after touchstart event.
  if (event is PointerDownEvent) {
    _addPointerDownEventToMatchedRecognizers(event);
  }

  if (event is PointerUpEvent || event is PointerCancelEvent) {
    _removePoint(touchPoint);
    _unbindEventTargetWithTouchPoint(touchPoint);
    // Clear target in the next task or start a timer.
    _startClearTargetTask();
  }
}