我正在使用颤振本地通知,我想了解它的时间。在 date_time.dart 中,这是颤振本地通知中使用的代码文件,我发现:
"The hour of the day, expressed as in a 24-hour clock [0..23]."
这意味着我需要在上午 8 点创建通知,我应该输入代码 07。但是颤振本地通知的示例,通知意味着在上午 10 点,但在他们写的代码中 10。这意味着范围是 [1..24],不是吗? 调度示例代码为:
Future<void> _scheduleDailyTenAMNotification() async {
await flutterLocalNotificationsPlugin.zonedSchedule(
0,
'daily scheduled notification title',
'daily scheduled notification body',
_nextInstanceOfTenAM(),
const NotificationDetails(
android: AndroidNotificationDetails(
'daily notification channel id',
'daily notification channel name',
'daily notification description'),
),
androidAllowWhileIdle: true,
uiLocalNotificationDateInterpretation:
UILocalNotificationDateInterpretation.absoluteTime,
matchDateTimeComponents: DateTimeComponents.time);
}
tz.TZDateTime _nextInstanceOfTenAM() {
final tz.TZDateTime now = tz.TZDateTime.now(tz.local);
tz.TZDateTime scheduledDate =
tz.TZDateTime(tz.local, now.year, now.month, now.day, 10);
if (scheduledDate.isBefore(now)) {
scheduledDate = scheduledDate.add(const Duration(days: 1));
}
return scheduledDate;
}