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:
init() is idempotent — if called a second time it returns immediately without re-initializing the plugin.
Public API
init() → Future<void>
init() → Future<void>
Performs one-time plugin setup:
- Calls
tz.initializeTimeZones()from thetimezonepackage and sets the local timezone toAmerica/Guayaquil. If the timezone lookup fails (e.g., on an unusual device configuration), it silently falls back to the device’s default local timezone. - Configures
AndroidInitializationSettingswith the app launcher icon (@mipmap/ic_launcher). - Initializes the
FlutterLocalNotificationsPluginwith anonDidReceiveNotificationResponsecallback (tapping a notification opens the app normally; deep-link navigation can be wired in here when a navigator key is available). - Calls
requestNotificationsPermission()on the Android-specific plugin implementation to prompt the user for thePOST_NOTIFICATIONSpermission on Android 13+.
scheduleReminders(ReminderSettings settings, String locale) → Future<void>
scheduleReminders(ReminderSettings settings, String locale) → Future<void>
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()
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.showTestNotification(String locale) → Future<void>
showTestNotification(String locale) → Future<void>
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."
cancelAll() → Future<void>
cancelAll() → Future<void>
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 ID | Name | Description | Priority |
|---|---|---|---|
active_breaks | Pausas Activas | Active break reminders during work hours | High |
daily_exercise | Ejercicio Diario | Daily exercise alarm at a user-configured hour | High |
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
workStartHouror at/afterworkEndHour, the notification is moved to the nextworkStartHour. - Night silence window — if the scheduled hour falls within
nightSilenceStartHour–nightSilenceEndHour, the notification is also moved to the nextworkStartHour. The window supports overnight ranges (e.g., 20:00–06:00) by checking for thestartHour > endHourwraparound case.
Rotating Messages
Ten body messages per language rotate so the teacher sees variety. The starting index is offset byDateTime.now().minute % 10, which means repeated calls to scheduleReminders() do not always begin with the same message.
Spanish messages (10 total):
"Pausa activa: estira cuello y hombros durante 2 minutos.""Hidratación: toma un vaso de agua ahora.""Descansa la vista: mira un punto lejano durante 20 segundos.""Respira profundo: inhala 4 s, retén 4 s, exhala 4 s.""Pausa de hombros: eleva y suelta 5 veces lentamente.""Levántate y camina 2 minutos. Tu cuerpo lo agradece.""Estira la espalda: entrelaza los dedos y estira hacia arriba.""Parpadea 20 veces para relajar los ojos.""Mueve los tobillos en círculos mientras estás sentado.""Gira el cuello suavemente de lado a lado, sin forzar."
_messagesQu).