flutter_fit_events 1.0.0
flutter_fit_events: ^1.0.0 copied to clipboard
A flutter package that handles listening and publishing events throughout your app.
A flutter package that handles listening and publishing events throughout your app, with the observer pattern.
Features #
- Publish events
- Listen to all events
- Listen to specific types of events
Getting started #
- Go inside your pubspec.yaml file
- Add this line under the dependencies:
flutter_fit_events: ^1.0.0
- Get dependencies
flutter pub get
Usage #
First, AppEventsDispatcher is a Singleton, so you can use it easily everywhere.
- Send an event for dispatch with
AppEventsDispatcher().publish(event) - Listen to all events with
AppEventsDispatcher().stream.listen((AppEvent event) {}) - Listen to a specific type of event with
AppEventsDispatcher().listenTo<AppEventType>((AppEvent event) {})
Additional information #
Inspired from this article. Feel free to give any feedback ! This package is also open to contributions.