flutter - 如何使用 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
BlocListener
在应用程序中使用 Bloc 并根据 Bloc 状态显示收听 Bloc
推荐阅读
- multithreading - 以编程方式停止 tensorflow 训练过程
- php - 如何在谷歌柱形图的列周围添加笔划?
- eclipse - Eclipse 4.18.0 无法打开市场 - NullPointerException
- typescript - Typescript 函数返回类型取决于参数的数量或类型
- c# - 我需要制作一些(逻辑乘法)程序,但我无法修复其中一个错误
- css - css 文件中的 css 变量未正确处理
- ios - NavigationView 上的全屏平移滑动手势?
- mongodb - mongo 删除/拉深嵌套数组中的孙子项
- jdbc - 遇到 SQL 错误:net.snowflake.client.jdbc.SnowflakeSQLException: Statement is closed
- javascript - 从列表中循环javascript