addEventListener<T> method

bool addEventListener<T>(
  1. EventListener<T> listener
)

Adds a listener to the emitter. When an event is emitted, the listeners added will be matched.

This methods calls the onAdd method of the listener.

Implementation

bool addEventListener<T>(EventListener<T> listener) {
  final added = listeners.add(listener);
  if (added) listener.onAdd?.call(this);
  return added;
}