addEventListener method
type
- The type of event to listen to.
listener
- The function that gets called when the event is fired.
Adds a listener to an event type.
Implementation
void addEventListener(String type, Function listener) {
_listeners ??= {};
Map<String, List<Function>> listeners = _listeners!;
if (listeners[type] == null) {
listeners[type] = [];
}
if (!listeners[type]!.contains(listener)) {
listeners[type]!.add(listener);
}
}