dispatchEvent method Null safety

  1. @override
void dispatchEvent (
  1. PointerEvent event,
  2. HitTestResult? hitTestResult
)
override

Dispatch an event to pointerRouter and the path of a hit test result.

The event is routed to pointerRouter. If the hitTestResult is not null, the event is also sent to every HitTestTarget in the entries of the given HitTestResult. Any exceptions from the handlers are caught.

The hitTestResult argument may only be null for PointerAddedEvents or PointerRemovedEvents.

Implementation

@override // from GestureBinding
void dispatchEvent(PointerEvent event, HitTestResult? hitTestResult) {
  if (hitTestResult != null ||
      event is PointerAddedEvent ||
      event is PointerRemovedEvent) {
    assert(event.position != null);
    _mouseTracker!.updateWithEvent(event,
        () => hitTestResult ?? renderView.hitTestMouseTrackers(event.position));
  }
  super.dispatchEvent(event, hitTestResult);
}