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

Getting Started

flutter_notification_center is available through pub.dev.

Add the dependency to your pubspec.yaml:

dependencies:
  ...
  flutter_notification_center: ^0.0.`2`

Usage example

Check the example folder

Subscribe observer

FlutterNotificationCenter().addObserver('updateProfileInfo', () {
  
  // here update the profile
  setState(() {
    
  });
});

or

FlutterNotificationCenter().addObserver('updateProfileInfo', _updateProfileInfo);

...

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

Remove observer

NotificationCenter().removeObserver('updateProfileInfo');

Post notification

FlutterNotificationCenter().post('updateProfileInfo');

Passing data

FlutterNotificationCenter().post('updateProfileInfo', (String name) {
  setState(() {
    log(name);
  });
});
FlutterNotificationCenter().post('updateProfileInfo', data: 10);