pub version points likes popularity
sdk platform Awesome Flutter

Mitt (anyone-dart-mitt)

This package help you to use event emitter/pubsub with dart. The package is inspired by npm mitt. I just take same name because user would easily to use it with same way without any hesitate.

If you like my module, please buy me a coffee.

More and more tiny and useful GitHub action modules are on the way. Please donate to me. I accept a part-time job contract. if you need, please contact me:

How to use

Same with mitt

import 'package:mitt/mitt.dart';

void main() {
  final emitter = Mitt();
  // listen to an event
  emitter.on(Symbol('foo'), eventHandler: (e) => print('foo $e'));

  // listen to all events
  emitter.on(Symbol('*'), wildcardHandler: (type, e) => print('$type $e'));

  // fire an event
  emitter.emit(Symbol('foo'), [
    <String, String>{'a': 'b'}

  // clearing all events

  // working with handler references:
  onFoo(arg) => print('defined onFoo with $arg');

  emitter.on(Symbol('foo'), eventHandler: onFoo); // listen'foo'), eventHandler: onFoo); // unlisten

You can reference example from example folder