Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Cristiang1021/ErgoKawsay/llms.txt

Use this file to discover all available pages before exploring further.

NotificationService is a singleton that wraps flutter_local_notifications to schedule two types of recurring reminders on Android: active break reminders and a daily exercise alarm. All notifications are local — no push infrastructure or internet connection is required.

Initialization

The service is initialized in _bootstrapNotifications(), which is called after runApp() to avoid blocking the UI thread during startup:
await NotificationService.instance.init();
await NotificationService.instance.scheduleReminders(settings, locale);
init() is idempotent — if called a second time it returns immediately without re-initializing the plugin.

Public API

Performs one-time plugin setup:
  1. Calls tz.initializeTimeZones() from the timezone package and sets the local timezone to America/Guayaquil. If the timezone lookup fails (e.g., on an unusual device configuration), it silently falls back to the device’s default local timezone.
  2. Configures AndroidInitializationSettings with the app launcher icon (@mipmap/ic_launcher).
  3. Initializes the FlutterLocalNotificationsPlugin with an onDidReceiveNotificationResponse callback (tapping a notification opens the app normally; deep-link navigation can be wired in here when a navigator key is available).
  4. Calls requestNotificationsPermission() on the Android-specific plugin implementation to prompt the user for the POST_NOTIFICATIONS permission on Android 13+.
The primary scheduling entry point. Cancels all existing notifications first, then — if settings.notificationsActive is true — schedules:
  • 8 break reminder notifications (IDs 100–107) via _scheduleBreakReminders()
  • 1 daily exercise alarm (ID 200) via _scheduleDailyExercise()
Each notification is scheduled with zonedSchedule using AndroidScheduleMode.inexactAllowWhileIdle for battery efficiency and DateTimeComponents.time so it repeats daily at the same time.The locale parameter ('es' or 'qu') selects which language to use for notification body text.
Immediately shows a test notification using plugin.show() (not scheduled). Useful for verifying that notifications are working from the Settings screen. The body text is:
  • Spanish: "Pausa activa: estira cuello y hombros."
  • Kichwa: "Kawsay sayay: kunkata, rikrak'ta samachiy."
Calls FlutterLocalNotificationsPlugin.cancelAll() to cancel all pending and displayed notifications across both channels. Called automatically at the start of scheduleReminders() to ensure a clean slate.

Notification Channels

Two Android notification channels are registered:
Channel IDNameDescriptionPriority
active_breaksPausas ActivasActive break reminders during work hoursHigh
daily_exerciseEjercicio DiarioDaily exercise alarm at a user-configured hourHigh

Work Hours & Night Silence Logic

To respect the teacher’s schedule, break reminders are skipped when the calculated fire time falls outside the configured boundaries:
  • Outside work hours — if the scheduled hour is before workStartHour or at/after workEndHour, the notification is moved to the next workStartHour.
  • Night silence window — if the scheduled hour falls within nightSilenceStartHournightSilenceEndHour, the notification is also moved to the next workStartHour. The window supports overnight ranges (e.g., 20:00–06:00) by checking for the startHour > endHour wraparound case.
Default silence window as shown in the reminders screen: 20:00–06:00 without notifications. When a notification is pushed to the next work-start time, the 8-break sequence continues from that rescheduled anchor, so breaks remain evenly spaced throughout the working day.

Rotating Messages

Ten body messages per language rotate so the teacher sees variety. The starting index is offset by DateTime.now().minute % 10, which means repeated calls to scheduleReminders() do not always begin with the same message. Spanish messages (10 total):
  1. "Pausa activa: estira cuello y hombros durante 2 minutos."
  2. "Hidratación: toma un vaso de agua ahora."
  3. "Descansa la vista: mira un punto lejano durante 20 segundos."
  4. "Respira profundo: inhala 4 s, retén 4 s, exhala 4 s."
  5. "Pausa de hombros: eleva y suelta 5 veces lentamente."
  6. "Levántate y camina 2 minutos. Tu cuerpo lo agradece."
  7. "Estira la espalda: entrelaza los dedos y estira hacia arriba."
  8. "Parpadea 20 veces para relajar los ojos."
  9. "Mueve los tobillos en círculos mientras estás sentado."
  10. "Gira el cuello suavemente de lado a lado, sin forzar."
Kichwa equivalents follow the same rotation order (defined in _messagesQu).
The current implementation only configures Android notifications. The InitializationSettings object is constructed with only the android: parameter — iOS initialization settings are not yet implemented. Notifications will not fire on iOS devices.

Build docs developers (and LLMs) love