scheduleDailyReminder method

Future<void> scheduleDailyReminder({
  1. required int hour,
  2. required int minute,
  3. required int dueCardCount,
})

Schedule the daily study reminder at a specific time.

Implementation

Future<void> scheduleDailyReminder({
  required int hour,
  required int minute,
  required int dueCardCount,
}) async {
  await _plugin.cancel(NotificationIds.dailyReminder);

  final body = dueCardCount > 0
      ? 'You have $dueCardCount card${dueCardCount == 1 ? '' : 's'} due for review'
      : 'No cards due — keep your streak going!';

  await _plugin.zonedSchedule(
    NotificationIds.dailyReminder,
    'Time to study',
    body,
    _nextInstanceOfTime(hour, minute),
    const NotificationDetails(
      iOS: DarwinNotificationDetails(
        presentAlert: true,
        presentBadge: true,
        presentSound: true,
      ),
    ),
    uiLocalNotificationDateInterpretation:
        UILocalNotificationDateInterpretation.absoluteTime,
    androidScheduleMode: AndroidScheduleMode.inexactAllowWhileIdle,
    matchDateTimeComponents: DateTimeComponents.time,
    payload: '/review',
  );
}