Notification Center

Pub Version

A notification dispatch mechanism that enables the broadcast of information to registered observers.

Getting Started

notification_center is available through pub.dev.

Add the dependency to your pubspec.yaml:

dependencies:
  ...
  notification_center: ^0.0.3

Usage example

Check the example folder

Subscribe observer

NotificationCenter().subscribe('updateCounter', () {
  setState(() {
    _counter++;
  });
});

or

NotificationCenter().subscribe('updateCounter', _updateCounter);

...

void _updateCounter() {
  setState(() {
    _counter++;
  });
}

Unsubscribe observer

NotificationCenter().unsubscribe('updateCounter');

Post notification

NotificationCenter().notify('updateCounter');

Passing data

NotificationCenter().subscribe('updateCounter', (int value) {
  setState(() {
    _counter = value;
  });
});
NotificationCenter().notify('updateCounter', data: 10);

Libraries

notification_center
A simple notification center. A notification dispatch mechanism that enables the broadcast of information to registered observers.