Flutter Local Notifications Provider

pub package

It adds a functionality in the main package .

Features

  • Adding FlutterLocalNotificationsPlugin into Widget Tree via InheritedWidget

Example

After you are done with basic setup, you just need to add this into Widget Tree

@override
Widget build(BuildContext context) {
    return NotificationProvider(
        service: flutterLocalNotificationsPlugin,
        child: MaterialApp(
            title: 'Title',
            theme: new ThemeData(
                primarySwatch: Colors.blue,
            ),
            home: widget.home),
    );
}

NotificationProvider needs plugins's reference.

You can access it using NotificationProvider.of(context);, for example:

...
        child: RaisedButton(
          onPressed: () async {
            await _showNotification(context);
          },
          child: Text('Test with notification'),
        ),
....

  Future _showNotification(BuildContext context) async {
    var plugin = NotificationProvider.of(context);
    var androidPlatformChannelSpecifics = AndroidNotificationDetails(
        'your channel id', 'your channel name', 'your channel description',
        importance: Importance.Max, priority: Priority.High);
    var iOSPlatformChannelSpecifics = IOSNotificationDetails();
    var platformChannelSpecifics = NotificationDetails(
        androidPlatformChannelSpecifics, iOSPlatformChannelSpecifics);
    await plugin.show(0, 'Title', 'Description',
        platformChannelSpecifics);
  }

Libraries

flutter_local_notifications_provider