簡體   English   中英

如何使用 Flutter_bloc 顯示通知

[英]How to show notification by using Flutter_bloc

我是 flutter_bloc 包的新手。 如何使用 flutter_bloc 包顯示通知警報。 這是我在不使用 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);
                    },
                  )

如果要在單擊IconButton時顯示一些通知,可以使用 BlocListener:

  1. 首先,為bloc中的通知制定business logic
  2. 使用BlocProvider提供 Bloc
  3. 在應用程序中使用BlocListener並根據 Bloc 狀態顯示收聽 Bloc

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM