[英]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:
business logic
BlocProvider
提供 BlocBlocListener
並根據 Bloc 狀態顯示收聽 Bloc
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.