Coder Social home page Coder Social logo

alefcarlos / flutter_local_notifications_provider Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 0.0 62 KB

Adding FlutterLocalNotificationsPlugin into Widget Tree via InheritedWidget

License: Other

Java 11.00% Dart 60.71% Ruby 21.09% Objective-C 7.19%
flutter dependency-injection

flutter_local_notifications_provider's Introduction

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);
  }

flutter_local_notifications_provider's People

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.