removeListener method

void removeListener(
  1. String eventName,
  2. EventCallback? callback
)

Unsubscribe from getting any future events from emitter. This mechanism uses event name and callback to unsubscribe from all possible events.

Implementation

void removeListener(String eventName, EventCallback? callback) {
  if (null == callback) {
    throw ArgumentError.notNull("callback");
  }

  // Check if listeners have the specific event already registered.
  // if so, then check for the callback registration.

  if (this._listeners.containsKey(eventName)) {
    Set<EventListener>? subs = this._listeners[eventName];
    subs?.removeWhere((element) =>
        element.eventName == eventName && element.callback == callback);
  }
}