dispatchEvent method

void dispatchEvent(
  1. Event event
)
inherited

Implementation

void dispatchEvent(Event event) {
  if (_listeners == null || _listeners!.isEmpty) return;

  var listeners = _listeners!;
  var listenerArray = listeners[event.type];

  // print("dispatchEvent event: ${event.type} ");

  if (listenerArray != null) {
    event.target = this;

    // Make a copy, in case listeners are removed while iterating.
    var array = listenerArray.sublist(0);

    for (var i = 0, l = array.length; i < l; i++) {
      Function fn = array[i];

      fn(event);
    }

    event.target = null;
  }
}