dart_notification_center 1.0.0+1


A lightweight and intuitive observer pattern manager for Dart/Flutter in the style of the iOS Notification Center

Installation #

To use this plugin, add dart_notification_center as a dependency in your pubspec.yaml file.

Import the package using:

import 'package:dart_notification_center/dart_notification_center.dart';

Usage #

A simple example:


  channel: 'examples',
  observer: this,
  onNotification: (options) {
    print('Notified: ${options}');

FlutterNotificationCenter.post(channel: 'examples', options: 'Congrats you did it!');

FlutterNotificationCenter.unsubscribe(channel: 'examples', observer: this);


0.0.0 #

  • Initial version, created by Stagehand

0.1.0 #

  • Implemented version, functional.
  • Needs testing

0.1.1 #

  • Knock down version requirement for test

0.1.2 #

  • Much better. Should integrate well now

0.1.3 #

  • Fixed the subscription method, subscriptions should listen properly now

0.2.0 #

  • Callbacks are now handled asynchronously to improve performance

1.0.0 #

  • Some general package improvements.
  • Removed an assertion on posting that was unnecessary, if not counterproductive.
  • Stable for first full version

1.0.0+1 #

  • Fixed the badge to refer to the correct package.


import 'package:dart_notification_center/dart_notification_center.dart';

main() {
  DartNotificationCenter.registerChannel(channel: 'an_event');

  //this is our notification observer object
  int i = 1;

  //This is our channel name
  String CHANNEL_NAME = 'an_event';

    channel: CHANNEL_NAME,
    observer: i,
    onNotification: (result) => print('received: $result'),

  // Expected: received: null
  DartNotificationCenter.post(channel: CHANNEL_NAME);

  // Expected: received: with options!!
    channel: CHANNEL_NAME,
    options: 'with options!!',

  DartNotificationCenter.unsubscribe(observer: i, channel: CHANNEL_NAME);

  DartNotificationCenter.unregisterChannel(channel: CHANNEL_NAME);

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  dart_notification_center: ^1.0.0+1

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:dart_notification_center/dart_notification_center.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Feb 13, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.5


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.2.0 <3.0.0
meta ^1.1.6 1.1.8
Dev dependencies
pedantic ^1.0.0
test ^1.0.0