dart_notification_center 0.1.0 copy "dart_notification_center: ^0.1.0" to clipboard
dart_notification_center: ^0.1.0 copied to clipboard

outdated

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
0
pub points
84%
popularity

Publisher

unverified uploader

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

Homepage

License

unknown (LICENSE)

Dependencies

meta

More

Packages that depend on dart_notification_center