dart_notification_center 1.0.0+1

Dart native js
Flutter Android iOS web

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);
}
9
likes
110
pub points
88%
popularity

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

Homepage

Documentation

API reference

Uploader

flyrboy96@gmail.com

License

MIT (LICENSE)

Dependencies

meta

More

Packages that depend on dart_notification_center