removeListener method

void removeListener(
  1. T event,
  2. EventCallback callback
)

Unsubscribe from getting any future events from emitter. This mechanism uses event and callback to unsubscribe from all possible events. event - Event for the subscription. callback - EventCallback used when registering subscription using on function.

Implementation

void removeListener(T event, EventCallback callback) {
  // Check if listeners have the specific event already registered.
  // if so, then check for the callback registration.

  if (_listeners.containsKey(event)) {
    final subs = _listeners[event]!;
    subs.removeWhere(
        (element) => element.event == event && element.callback == callback);
  }
}