Android 颤振每周计划重复通知未按预期工作

Android 颤振每周计划重复通知未按预期工作,android,flutter,dart,notifications,flutter-local-notification,Android,Flutter,Dart,Notifications,Flutter Local Notification,插件 我使用的是最新版本(6.0.0) 应用程序 我正在开发一个提醒应用程序,用户可以将本地通知设置为每周在选定的几天显示,每X小时重复一次。通知可以有开始时间和结束时间。例如,将通知设置为在每个周六、周日、周三从08:30开始显示,在15:30结束,并在这两个时间(8:30、10:30、12:30、14:30)之间每隔2小时重复一次。为了简化,我将为每周的每一天设置通知 错误 问题是,它有时显示通知,有时不显示通知。第一个通知始终显示(在上面的示例中为8:30),但其他通知有时不显示。我确实设

插件

我使用的是最新版本(6.0.0)

应用程序

我正在开发一个提醒应用程序,用户可以将本地通知设置为每周在选定的几天显示,每X小时重复一次。通知可以有开始时间和结束时间。例如,将通知设置为在每个周六、周日、周三从08:30开始显示,在15:30结束,并在这两个时间(8:30、10:30、12:30、14:30)之间每隔2小时重复一次。为了简化,我将为每周的每一天设置通知

错误

问题是,它有时显示通知,有时不显示通知。第一个通知始终显示(在上面的示例中为8:30),但其他通知有时不显示。我确实设置了所有通知

我的规格

我正在使用最新版本的插件(6.0.0)。我的手机是LG V20,安卓8.0。颤振版本为2.2.0(本期末尾的颤振医生)

代码示例

我的代码有点复杂。我可以提供完整的代码,但很难理解。我将提供我认为需要的部分。我对代码进行了注释,使其易于理解,并将上面的示例用作此函数的数据:

void show notificationweekly(
int id、字符串标题、字符串正文、提醒)异步{
//初始化时区
tz.initializeTimeZones();
最终字符串当前时区=
等待nativeTimeZone.getLocalTimezone();
打印(“时区=$currentTimeZone”);
tz.setLocalLocation(tz.getLocation(currentTimeZone));
//完成时区初始化
int_notificationId=0;
List _notificationIdList=[];//我想在共享Pref中设置ID,这就是此列表的用途
///[WeekValue]是一个由7个布尔组成的数组,0到6表示一周中的每一天
///在这个循环中,我为用户选择的一周中的几天设置了所有通知
///在我们的示例中,我们选择了一周中的所有日子,因此[WeekValue]是由7个真布尔值组成的数组。
对于(var i=0;i0){
while(_weekDateTime.isBefore(_timeEnd)){
///此打印的输出很重要,将在此代码之后提供
印刷品(
'如果Id为$_notificationId的通知已成功安排在$_weekDateTime');
等待本地通知规划分区时间表(
_通知ID,
标题
身体,
//_temp,
_添加(持续时间(秒:1)),
getPlatformChannelSpecfics(),
安德罗德洛维希莱德:是的,
UILocalNotificationDate解释:
UILocalNotificationDateExpansion.absoluteTime,
matchDateTimeComponents:DateTimeComponents.dayOfWeekAndTime);
///一些递增的东西
_notificationIdList.add(_notificationId);
_notificationId++;
///添加到重复时间的时基
///在本例中,如果第一个循环将2小时加到8:30,那么结果是10:30
_weekDateTime=\u weekDateTime.add(
持续时间(
小时数:提醒。时间值[2][0],
),
);
}
}else{//由于我们选择了所有的工作日,因此可以忽略此else
tz.TZDateTime _temp=tz.TZDateTime(
tz.本地,
_weekDateTime.year,
_weekDateTime.month,
_weekDateTime.day,
_weekDateTime.hour,
_weekDateTime.minute,
_weekDateTime.second,
_weekDateTime.毫秒,
_weekDateTime.微秒,
);
印刷品(
'Id为=$的else通知计划在$临时';
_notificationIdList.add(_notificationId);
等待本地通知规划分区时间表(
_通知ID,
标题
身体,
//_temp,
_临时工,
getPlatformChannelSpecfics(),
安德罗德洛维希莱德:是的,
UILocalNotificationDate解释:
UILocalNotificationDateExpansion.absoluteTime,
matchDateTimeComponents:DateTimeComponents.dayOfWeekAndTime);
}
_notificationId++;
}
}
等待SetNotificationId(_notificationIdList);
}
打印输出:


I/flutter ( 7643): Notification with Id= 0 Succesfuly Scheduled at 2021-05-24 08:30:00.000+0430
I/flutter ( 7643): Notification with Id= 1 Succesfuly Scheduled at 2021-05-24 10:30:00.000+0430
I/flutter ( 7643): Notification with Id= 2 Succesfuly Scheduled at 2021-05-24 12:30:00.000+0430
I/flutter ( 7643): Notification with Id= 3 Succesfuly Scheduled at 2021-05-24 14:30:00.000+0430
I/flutter ( 7643): Notification with Id= 5 Succesfuly Scheduled at 2021-05-25 08:30:00.000+0430
I/flutter ( 7643): Notification with Id= 6 Succesfuly Scheduled at 2021-05-25 10:30:00.000+0430
I/flutter ( 7643): Notification with Id= 7 Succesfuly Scheduled at 2021-05-25 12:30:00.000+0430
I/flutter ( 7643): Notification with Id= 8 Succesfuly Scheduled at 2021-05-25 14:30:00.000+0430
I/flutter ( 7643): Notification with Id= 10 Succesfuly Scheduled at 2021-05-26 08:30:00.000+0430
I/flutter ( 7643): Notification with Id= 11 Succesfuly Scheduled at 2021-05-26 10:30:00.000+0430
I/flutter ( 7643): Notification with Id= 12 Succesfuly Scheduled at 2021-05-26 12:30:00.000+0430
I/flutter ( 7643): Notification with Id= 13 Succesfuly Scheduled at 2021-05-26 14:30:00.000+0430
I/flutter ( 7643): Notification with Id= 15 Succesfuly Scheduled at 2021-05-27 08:30:00.000+0430
I/flutter ( 7643): Notification with Id= 16 Succesfuly Scheduled at 2021-05-27 10:30:00.000+0430
I/flutter ( 7643): Notification with Id= 17 Succesfuly Scheduled at 2021-05-27 12:30:00.000+0430
I/flutter ( 7643): Notification with Id= 18 Succesfuly Scheduled at 2021-05-27 14:30:00.000+0430
I/flutter ( 7643): Notification with Id= 20 Succesfuly Scheduled at 2021-05-28 08:30:00.000+0430
I/flutter ( 7643): Notification with Id= 21 Succesfuly Scheduled at 2021-05-28 10:30:00.000+0430
I/flutter ( 7643): Notification with Id= 22 Succesfuly Scheduled at 2021-05-28 12:30:00.000+0430
I/flutter ( 7643): Notification with Id= 23 Succesfuly Scheduled at 2021-05-28 14:30:00.000+0430
I/flutter ( 7643): Notification with Id= 25 Succesfuly Scheduled at 2021-05-29 08:30:00.000+0430
I/flutter ( 7643): Notification with Id= 26 Succesfuly Scheduled at 2021-05-29 10:30:00.000+0430
I/flutter ( 7643): Notification with Id= 27 Succesfuly Scheduled at 2021-05-29 12:30:00.000+0430
I/flutter ( 7643): Notification with Id= 28 Succesfuly Scheduled at 2021-05-29 14:30:00.000+0430
I/flutter ( 7643): Notification with Id= 30 Succesfuly Scheduled at 2021-05-30 08:30:00.000+0430
I/flutter ( 7643): Notification with Id= 31 Succesfuly Scheduled at 2021-05-30 10:30:00.000+0430
I/flutter ( 7643): Notification with Id= 32 Succesfuly Scheduled at 2021-05-30 12:30:00.000+0430
I/flutter ( 7643): Notification with Id= 33 Succesfuly Scheduled at 2021-05-30 14:30:00.000+0430

颤振医生

flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 2.2.0, on Microsoft Windows [Version 10.0.19042.985], locale en-US)
[√] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[√] Chrome - develop for the web
[!] Android Studio (not installed)
[√] VS Code (version 1.56.2)
[√] Connected device (3 available)

! Doctor found issues in 1 category.
请帮我解决这个问题。任何帮助都将不胜感激