scheduleStreakAlert method

Future<void> scheduleStreakAlert({
  1. required int currentStreak,
})

Schedule streak maintenance alert at 8pm daily.

Implementation

Future<void> scheduleStreakAlert({required int currentStreak}) async {
  await _plugin.cancel(NotificationIds.streakAlert);

  if (currentStreak <= 0) return;

  await _plugin.zonedSchedule(
    NotificationIds.streakAlert,
    'Keep your streak alive!',
    "You're on a $currentStreak-day streak. Don't forget to study today.",
    _nextInstanceOfTime(20, 0),
    const NotificationDetails(
      iOS: DarwinNotificationDetails(
        presentAlert: true,
        presentBadge: false,
        presentSound: true,
      ),
    ),
    uiLocalNotificationDateInterpretation:
        UILocalNotificationDateInterpretation.absoluteTime,
    androidScheduleMode: AndroidScheduleMode.inexactAllowWhileIdle,
    matchDateTimeComponents: DateTimeComponents.time,
    payload: '/review',
  );
}