ErgoKawsay is structured as a feature-based Flutter application — each well-being module lives in its own folder underDocumentation 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.
lib/features/, keeping screens, logic, and widgets co-located and easy to navigate. All application state (locale, theme, and accessibility settings) is managed through ChangeNotifier controllers exposed via the Provider package. There is no backend, no REST client, and no network dependency: all data is served from LocalDataRepository, a singleton that holds every module’s content in memory at runtime. Navigation is handled through Flutter’s MaterialApp.routes map, with all named routes defined centrally in app.dart.
Directory Structure
Named Routes
All routes are registered in theroutes map of MaterialApp inside app.dart. Navigation throughout the app uses Navigator.pushNamed with these paths:
| Route | Screen Class | Description |
|---|---|---|
/ | SplashScreen | Animated splash; decides whether to show language selection or home |
/language | LanguageSelectionScreen | First-run language picker (Spanish / Kichwa) |
/teacher-profile | TeacherProfileScreen | Teacher name and avatar setup |
/home | HomeScreen | Main module grid dashboard |
/ergonomics | ErgonomicsScreen | Interactive ergonomics story deck and quiz |
/diseases | DiseasesScreen | Musculoskeletal disease reference cards |
/active-breaks | ActiveBreaksScreen | Guided 5-minute active-break sequence |
/exercises | ExercisesScreen | Body-area exercise library |
/reminders | RemindersScreen | Local notification scheduler |
/tips | TipsScreen | Rotating preventive tips |
/emotions | EmotionsScreen | Emotional health module with characters |
/music | MusicScreen | Ambient audio player |
/videos | VideosScreen | Integrated educational video player |
/progress | ProgressScreen | Module usage and habit tracking |
/settings | SettingsScreen | Language, theme, accessibility, and app info |
State Management
ErgoKawsay uses the Provider package for all global reactive state. ThreeChangeNotifier controllers are instantiated in _ErgoKawsayAppState.initState() and injected into the widget tree via custom InheritedWidget-based scopes defined in app.dart:
| Controller | Scope Widget | Responsibility |
|---|---|---|
LocaleController | LocaleControllerScope | Tracks and persists the active Locale (es or qu); exposes setLocale() |
ThemeController | ThemeControllerScope | Tracks and persists ThemeMode (light / dark / system) |
AccessibilityController | AccessibilityControllerScope | Manages text-scale factor and color-blind filter matrix |
StorageService on construction and write back to it on every change. They are merged into a single Listenable via Listenable.merge([...]) so the root MaterialApp rebuilds only once per state change, regardless of which controller fired.
StorageServiceScope wraps the entire widget tree at the outermost level, making the StorageService instance available to any widget that needs to read or write persistent data without going through a controller.
The accessibility controller applies a
ColorFiltered matrix over the entire app when the color-blind mode is enabled, and overrides the system textScaler via a root MediaQuery wrapper — both implemented in app.dart’s builder callback rather than in individual screens.Data Layer
LocalDataRepository
LocalDataRepository is a singleton (accessed via LocalDataRepository.instance) that acts as the single source of truth for all in-app content. It exposes getters for:
- Module cards — Ergonomics story deck, active-break steps
- Diseases — List of
Diseasemodel objects with descriptions and advice - Exercises —
Exerciseobjects grouped by body-area category - Tips — Preventive
Tipitems displayed in rotation - Emotions —
Emotionobjects with their associated characters - Music tracks — Asset paths and metadata for the audio player
- Videos — Asset paths and metadata for the video player
- Quiz data — Question sets for the ergonomics review quiz
pubspec.yaml.
StorageService
StorageService is a thin wrapper around SharedPreferences that provides typed read/write helpers for every persistent concern in the app:
| Key Constant | Data Stored |
|---|---|
AppConstants.keyLanguage | Selected language code (es / qu) |
AppConstants.keyThemeMode | Theme preference (light / dark / system) |
AppConstants.keyAccessibility | Accessibility settings (text scale, color-blind flag) |
AppConstants.keyProgress | Module-usage progress data |
AppConstants.keyReminders | Reminder schedule configuration |
AppConstants.keyNotificationsEnabled | Global notifications on/off toggle |
AppConstants.keyProfileName | Teacher’s display name |
AppConstants.keyProfileAvatar | Teacher’s selected avatar identifier |
AppConstants.keyProfileCompleted | Whether the profile setup flow has been completed |
StorageService.init() is async and must be awaited before runApp() so all controllers can read persisted state synchronously on first build.
App Entry Point
Themain() function in lib/main.dart follows a deliberate bootstrap order to keep startup fast and resilient:
GoogleFonts.config.allowRuntimeFetching = false— Prevents the app from attempting font downloads, which would fail silently or stall on devices without connectivity.StorageService.init()beforerunApp()— Ensures allChangeNotifiercontrollers have access to persisted preferences synchronously during their firstbuild, avoiding a flash of default state.unawaited(_bootstrapNotifications(...))— Notification scheduling is intentionally non-blocking. Failures are caught and logged viadebugPrintwithout crashing the app.