How do I trigger a notification for a particular time period using flutter_local_notification pacakage. I tried out the tutorial on pub.dev but I am still not able to do it. Someone, please help.
Here is my try to trigger it at 4:23 pm.
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, 16, 23));
if (scheduledDate.isBefore(now)) {
scheduledDate = scheduledDate.add(const Duration(days: 1));
}
return scheduledDate;
Future<void> displayNotification() async {
notificationsPlugin.zonedSchedule(
0,
"Wake Up",
'Time to wake up now',
_nextInstanceOfTenAM(),
//tz.TZDateTime.now(tz.local).add(Duration(seconds: 3)),
NotificationDetails(
android: AndroidNotificationDetails(
'channel id', 'channel name', 'channel description'),
),
uiLocalNotificationDateInterpretation:
UILocalNotificationDateInterpretation.absoluteTime,
androidAllowWhileIdle: true);
}