如何解决如何使用 dart-flutter 每天重复本地通知?以及如何将“2:00 AM”时间格式解析为 TimeZone?
我正在尝试对患者的用药时间进行每日剩余,我正在使用 Flutter_local_notifications 并且效果很好。 这是我的功能,我想让它每天重复,
void scheduleAlarm() async {
var androidplatformChannelSpecifics = AndroidNotificationDetails(
'alarm_notif','alarm_notif','Channel for Alarm notification',icon: 'codex_logo',sound: RawResourceAndroidNotificationSound('notification_sound'),largeIcon: DrawableResourceAndroidBitmap('drug'),);
tz.initializeTimeZones();
tz.setLocalLocation(tz.getLocation('America/Detroit'));
var iOSPlatformChannelSpecifics = IOSNotificationDetails(
sound: 'notification_sound.wav',presentAlert: true,presentBadge: true,presentSound: true);
var platformChannelSpecifics = NotificationDetails(
android: androidplatformChannelSpecifics,iOS: iOSPlatformChannelSpecifics);
await FlutterlocalnotificationsPlugin.zonedSchedule(
0,'Panadol','Don\'t forget to take your medicine 2:00 AM',tz.TZDateTime.Now(tz.local).add(Duration(seconds: 5)),platformChannelSpecifics,androidAllowWhileIdle: true,);
}
并且我想更改此行,以便我可以以这种格式传递从 TimePicker 获得的时间字符串 '2:00 AM'
tz.TZDateTime.Now(tz.local).add(Duration(seconds: 5)),
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。