dispatchEvent method

void dispatchEvent(
  1. Event event
)

event - The event that gets fired.

Fire an event type.

Implementation

void dispatchEvent(Event event) {
  if (_listeners == null || _listeners!.isEmpty) return;
  final listeners = _listeners!;
  final listenerArray = listeners[event.type];

  if (listenerArray != null) {
    event.target = this;
    final array = listenerArray.sublist(0);

    for (int i = 0, l = array.length; i < l; i++) {
      final Function fn = array[i];
      fn(event);
    }

    event.target = null;
  }
}