dispatchEvent method

  1. @override
void dispatchEvent(
  1. Event event
)
override

Dispatches the event to all listening subscribers.

Implementation

@override
void dispatchEvent(Event event) {
  final ancestors = <EventDispatcher>[];

  for (DisplayObject? p = parent; p != null; p = p.parent) {
    ancestors.add(p);
  }

  for (var i = ancestors.length - 1; i >= 0 && event.captures; i--) {
    ancestors[i].dispatchEventRaw(event, this, EventPhase.CAPTURING_PHASE);
    if (event.isPropagationStopped) return;
  }

  dispatchEventRaw(event, this, EventPhase.AT_TARGET);
  if (event.isPropagationStopped) return;

  for (var i = 0; i < ancestors.length && event.bubbles; i++) {
    ancestors[i].dispatchEventRaw(event, this, EventPhase.BUBBLING_PHASE);
    if (event.isPropagationStopped) return;
  }
}