scheduleOverdueWarning method
Schedule one-shot overdue warning.
Implementation
Future<void> scheduleOverdueWarning({
required DateTime nextReviewDate,
required int thresholdDays,
}) async {
await _plugin.cancel(NotificationIds.overdueWarning);
final fireAt = nextReviewDate.add(Duration(days: thresholdDays));
final now = DateTime.now();
if (fireAt.isBefore(now)) {
// Already overdue — schedule for tomorrow 9am as a nag.
final tomorrow9am = DateTime(now.year, now.month, now.day + 1, 9, 0);
await _scheduleOneShot(
id: NotificationIds.overdueWarning,
title: 'Overdue review cards',
body: 'You have cards that are overdue. Review them now!',
scheduledDate: tomorrow9am,
);
return;
}
await _scheduleOneShot(
id: NotificationIds.overdueWarning,
title: 'Review cards becoming overdue',
body: 'Some cards are now $thresholdDays+ days overdue. Time to review!',
scheduledDate: fireAt,
);
}