scheduleTaskNotifications method
Future<void>
scheduleTaskNotifications(
)
Implementation
Future<void> scheduleTaskNotifications() async {
try {
await AwesomeNotifications().cancelAll();
final List<CropTask> tasks = _hiveService.getAllTasks();
final DateTime now = DateTime.now();
final List<CropTask> todayTasks = tasks.where((task) =>
task.date.year == now.year &&
task.date.month == now.month &&
task.date.day == now.day).toList();
if (todayTasks.isNotEmpty) {
await _showTodayTasksNotification(todayTasks);
}
await _scheduleNextDayNotification();
} catch (e) {
debugPrint('Error scheduling notifications: $e');
}
}