Skip to content
pubscout

events_emitter

0.6.0, released 2 years ago by drafakiller.com

An intuitive event-based system inspired by NodeJS's Event Emitter with type safety.

WASM-ready
$ flutter pub add events_emitter
Source repository

What it does

Provides an event-based system with type safety, allowing multiple data types for events. It supports both callbacks and streams through EventEmitter and StreamEventEmitter, and can be extended to create custom event emitters.

AI-written summary of version 0.6.0, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You want a NodeJS-style event emitter in Dart or Flutter
  • You need type-safe event handling where multiple data types share an event type
  • You want to use both callbacks and streams for managing events

Skip it when

  • You already use a state management solution that covers your event communication needs
  • You prefer built-in StreamControllers without external abstractions

Strengths

  • Type-safe events allowing different data types on the same event type
  • Supports both callbacks and streams
  • Extensible classes to create custom event emitters and events

Weaknesses

  • Can introduce event-driven architectural complexity if overused in a UI codebase

Setup

Kind
Pure Dart
Effort
Low
Code generation
No
Direct dependencies
1
final events = EventEmitter();

events.on('message', (String data) => print('String: $data'));
events.on('message', (int data) => print('Integer: $data'));

events.emit('message', 'Hello World');
events.emit('message', 42);

Alternatives

Packages that do the same job and could replace events_emitter.

Works with

Packages commonly used together with events_emitter: ones it builds on, ones built on it, and its own family.