on method
Adds a listener for a specific event.
- Parameters:
- event: The name of the event to listen for.
- listener: The function to call when the event is emitted.
Implementation
void on(String event, Function(dynamic) listener) {
_listeners.putIfAbsent(event, () => []).add(listener);
}