notification_center 1.0.2 copy "notification_center: ^1.0.2" to clipboard
notification_center: ^1.0.2 copied to clipboard

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

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: ^1.0.2

Usage example #

Check the example folder

Add a subscribers

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

or

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

...

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

Remove subscribers

NotificationCenter().unsubscribe('updateCounter');

Post notification

NotificationCenter().notify('updateCounter');

Passing data

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

Pause/resume or cancel the subscription

final subscription = NotificationCenter().subscribe('updateCounter', (int data) {
  setState(() {
    _counter += data;
  });
});

//Do some work...

subscription.pause();
print(subscription.isPaused); // true

subscription.resume();
print(subscription.isPaused); // false

subscription.cancel();
10
likes
150
pub points
94%
popularity

Publisher

verified publisheraky.dev

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

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

More

Packages that depend on notification_center