removeListener method
- String eventName,
- EventCallback callback
Unsubscribe from getting any future events from emitter.
This mechanism uses event name and callback to unsubscribe from all possible events.
eventName
- Event name for the subscription.
callback
- EventCallback used when registering subscription using on function.
Implementation
void removeListener(String eventName, EventCallback callback) {
if (null == eventName || eventName.trim().isEmpty) {
throw ArgumentError.notNull("eventName");
}
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<Listener> subs = this._listeners[eventName];
subs.removeWhere((element) =>
element?.eventName == eventName && element?.callback == callback);
}
}