I’ve a reasonably easy situation concerning reminder scheduling in flutter. I’m simply attempting to set a primary reminder for one minute sooner or later (as a check, it might be 3 days sooner or later, 2 hours, and many others…). I’ve 2 code snippets under, one which works and one that doesn’t. The one distinction is how I set the TZDateTime. I’m very confused.
Why is that this code not working
var now = tz.TZDateTime.now(tz.native);
tz.TZDateTime scheduledDate = tz.TZDateTime(
tz.native,
now.12 months,
now.month,
now.day,
22,
47);
await flutterLocalNotificationsPlugin
.zonedSchedule(
1,
'scheduled title',
'scheduled physique',
scheduledDate,
NotificationDetails(
android: AndroidNotificationDetails(
'you_can_name_it_whatever',
'your channel title',
channelDescription:
'your channel description',
significance: Significance.max,
precedence: Precedence.max),
),
androidScheduleMode:
AndroidScheduleMode.exactAllowWhileIdle,
uiLocalNotificationDateInterpretation:
UILocalNotificationDateInterpretation
.absoluteTime,
matchDateTimeComponents:
DateTimeComponents.dayOfWeekAndTime,
);
} else {
flutterLocalNotificationsPlugin.cancel(1);
}
await flutterLocalNotificationsPlugin
.zonedSchedule(
1,
'scheduled title',
'scheduled physique',
scheduledDate,
const NotificationDetails(
android: AndroidNotificationDetails(
'you_can_name_it_whatever',
'your channel title',
channelDescription:
'your channel description',
significance: Significance.max,
precedence: Precedence.max),
),
androidScheduleMode:
AndroidScheduleMode.exactAllowWhileIdle,
uiLocalNotificationDateInterpretation:
UILocalNotificationDateInterpretation
.absoluteTime,
matchDateTimeComponents:
DateTimeComponents.dayOfWeekAndTime,
);
However this code is
await flutterLocalNotificationsPlugin
.zonedSchedule(
1,
'scheduled title',
'scheduled physique',
scheduledDate,
NotificationDetails(
android: AndroidNotificationDetails(
'you_can_name_it_whatever',
'your channel title',
channelDescription:
'your channel description',
significance: Significance.max,
precedence: Precedence.max),
),
androidScheduleMode:
AndroidScheduleMode.exactAllowWhileIdle,
uiLocalNotificationDateInterpretation:
UILocalNotificationDateInterpretation
.absoluteTime,
matchDateTimeComponents:
DateTimeComponents.dayOfWeekAndTime,
);
} else {
flutterLocalNotificationsPlugin.cancel(1);
}
await flutterLocalNotificationsPlugin
.zonedSchedule(
1,
'scheduled title',
'scheduled physique',
tz.TZDateTime.now(tz.native).add(Length(
seconds: 1)),
const NotificationDetails(
android: AndroidNotificationDetails(
'you_can_name_it_whatever',
'your channel title',
channelDescription:
'your channel description',
significance: Significance.max,
precedence: Precedence.max),
),
androidScheduleMode:
AndroidScheduleMode.exactAllowWhileIdle,
uiLocalNotificationDateInterpretation:
UILocalNotificationDateInterpretation
.absoluteTime,
matchDateTimeComponents:
DateTimeComponents.dayOfWeekAndTime,
);