Skip to content
pubscout

event_hub

0.2.1, released 4 years ago by an unverified publisher

An event bus library to dispatch and listen to events across your app using Dart streams.

WASM-ready
$ flutter pub add event_hub
Source repository

What it does

Provides a simple event hub mechanism to fire events and register listeners globally without needing dedicated event classes. It uses underlying Dart streams to communicate between decoupled components.

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

Use it when

  • You need a simple event bus to decouple components across your application.
  • You want to avoid defining custom event classes or heavy state management for simple messaging.
  • You need to dispatch events from anywhere and listen anywhere.

Skip it when

  • You need robust, typed state management with predictable state trees and debugging tools.
  • Your architecture benefits more from strict unidirectional data flows or inherited widgets.

Strengths

  • Extremely simple API with minimal boilerplate.
  • No need to define dedicated event classes.
  • Works across all Dart and Flutter platforms.

Weaknesses

  • Relies on dynamic data types for event payloads.
  • Global event buses can lead to untraceable code paths if overused.

Setup

Kind
Pure Dart
Effort
Low
Code generation
No
Direct dependencies
0
import 'package:event_hub/event_hub.dart';

EventHub eventHub = EventHub();

// Register
eventHub.on('yourEventName', (dynamic data) {
  print(data);
});

// Fire
eventHub.fire('yourEventName', 'some optional data');

Alternatives

Packages that do the same job and could replace event_hub.