-1

I am new in flutter_bloc package. How to show notification alert by using flutter_bloc package. Here is the example what i did without using bloc.

                  IconButton(
                    icon: Icon(Icons.notifications),
                    onPressed: () {
                      String time=7:30
                      List<String> arr = time.split(':');
                      int aa = int.parse(arr[0]);
                      int bb = int.parse(arr[1]);
                      var time = new Time(aa, bb, 0);
                      var android = new AndroidNotificationDetails(
                        'Channel Id', 'Channel Name', 'Channel Des',);
                      var iOS = new IOSNotificationDetails();
                      var platform = new NotificationDetails(android, iOS);
                      flutterLocalNotificationsPlugin.showDailyAtTime(0, 'show daily title',
                          'Daily notification shown at approximately', time, platform);
                    },
                  )
SOUGAT RIYADH
  • 562
  • 2
  • 10
  • 26

1 Answers1

1

If you want to show some notification when the IconButton is clicked, you can use BlocListener for it:

  1. Firstly, make business logic for notification in bloc
  2. Provide the Bloc using BlocProvider
  3. listen to Bloc using BlocListener in app and according to Bloc state show
thisisyusub
  • 670
  • 8
  • 20