scheduleTaskNotification method
Schedule a notification for a task
at the task.triggerTime
.
Implementation
@override
Future<void> scheduleTaskNotification(UserTask task) async {
// early out if not to be scheduled
if (!task.notification) return;
if (task.triggerTime.isAfter(DateTime.now())) {
final time = tz.TZDateTime.from(
task.triggerTime, tz.getLocation(Settings().timezone));
await FlutterLocalNotificationsPlugin().zonedSchedule(
task.id.hashCode,
task.title,
task.description,
time,
_platformChannelSpecifics,
androidScheduleMode: AndroidScheduleMode.exactAllowWhileIdle,
uiLocalNotificationDateInterpretation:
UILocalNotificationDateInterpretation.absoluteTime,
payload: task.id,
);
task.hasNotificationBeenCreated = true;
debug('$runtimeType - Notification scheduled for $task at $time');
} else {
warning('$runtimeType - Can only schedule a notification in the future. '
'task trigger time: ${task.triggerTime}.');
}
}