emit method

void emit(
  1. T event, [
  2. Object? data
])

API to emit events. event is a required parameter. If sender information is sent, it will be used to intimate user about it. event - What event needs to be emitted. data - Data the event need to carry. Ignore this argument if no data needs to be sent.

Implementation

void emit(T event, [Object? data]) {
  if (_listeners.containsKey(event)) {
    final sublist = _listeners[event]!.toList();
    for (final item in sublist) {
      item.callback(data);
    }
  }
}