dart_notification_center 1.0.0+1 copy "dart_notification_center: ^1.0.0+1" to clipboard
dart_notification_center: ^1.0.0+1 copied to clipboard

A wrapper for the observer pattern for Dart in the style of the iOS Notification Center.

example/dart_notification_center_example.dart

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';

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

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

  // Expected: received: with options!!
  DartNotificationCenter.post(
    channel: CHANNEL_NAME,
    options: 'with options!!',
  );

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

  DartNotificationCenter.unregisterChannel(channel: CHANNEL_NAME);
}
31
likes
30
points
26
downloads

Publisher

unverified uploader

Weekly Downloads

A wrapper for the observer pattern for Dart in the style of the iOS Notification Center.

Homepage

License

MIT (license)

Dependencies

meta

More

Packages that depend on dart_notification_center