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
void dispatchEvent(PointerEvent event, HitTestResult? hitTestResult) {
  switch (pointerEventSource) {
    case TestBindingEventSource.test:
      super.dispatchEvent(event, hitTestResult);
      break;
    case TestBindingEventSource.device:
      assert(hitTestResult != null || event is PointerAddedEvent || event is PointerRemovedEvent);
      assert(deviceEventDispatcher != null);
      if (hitTestResult != null) {
        deviceEventDispatcher!.dispatchEvent(event, hitTestResult);
      }
      break;
  }
}