Listener class Null safety

Listener is one who listen for specific event. Listener register for notification with EventEmitter Once the listener is registered, a Listener interface is returned back to the caller. Caller can use this Listener interface to cancel the registration or check the state.


Listener(String eventName, Object? context, EventCallback callback, CancelEvent? _cancelCallback)
Constructor for Listener. This will take four arguments. eventName, callback are mandatory. context, _cancelCallback are optional. if _cancelCallback callback is provided, then the listener can use that to cancel the subscription.
Listener.Default(String eventName, Object? context, EventCallback callback)
Constructor for Listener. This will take four arguments. eventName, callback are mandatory. context is optional.


callback EventCallback
The event callback, which the subscriber uses when he register it for.
context Object?
The context from which subscriber is interested in.
eventName String
The event name, the subscriber subscribed to.
hashCode int
The hash code for this object. [...]
read-only, inherited
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited


cancel() bool
Cancel the event subscription with the subject. Eventhough the cancel method is called, listener doesn't check the cancellation of the subscription. Subscription cancellation shall be implemented in the _cancelCallback function. The Default constructor doesn't provide a mechanism to cancel the subscription. Use the EventEmitter.on to cancel the suscrition effectively. Returns true, if _cancelCallback is successfully executed, false otherwise.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
toString() String
A string representation of this object. [...]


operator ==(Object other) bool
The equality operator. [...]