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.
StorageService is the single persistence layer for ErgoKawsay. It wraps SharedPreferences and exposes typed getters and setters for every stored datum — there is no remote backend. All data lives on-device, making the app fully offline and respecting user privacy.
Initialization
StorageService.init() is an async factory that calls SharedPreferences.getInstance() and wraps the result. It is called once in main() before runApp(), and the resulting instance is injected into the widget tree via StorageServiceScope so that controllers and screens can access it without re-instantiation.
API Reference
Language
Language
Controls the active UI language (
'es' for Spanish or 'qu' for Kichwa).| Method / Property | Return type | Description |
|---|---|---|
getLanguage() | String? | Returns 'es' or 'qu', or null if the user has not yet chosen a language. |
setLanguage(String code) | Future<void> | Persists the chosen language code to SharedPreferences. |
clearLanguage() | Future<void> | Removes the stored language key, causing the language selection screen to reappear on next launch. |
hasLanguage | bool | Returns true if a language has been saved (i.e. getLanguage() != null). |
Theme
Theme
Stores the user’s preferred
ThemeMode so the app restores it on next launch.| Method | Return type | Description |
|---|---|---|
getThemeMode() | ThemeMode | Reads the stored theme string and maps it to ThemeMode.light, ThemeMode.dark, or ThemeMode.system (default when no value is stored). |
setThemeMode(ThemeMode mode) | Future<void> | Converts the ThemeMode to its string constant and writes it to SharedPreferences. |
Notifications
Notifications
Global on/off switch for all local notifications.
| Method / Property | Return type | Description |
|---|---|---|
notificationsEnabled | bool | Returns the stored value, defaulting to true when no value has been set. |
setNotificationsEnabled(bool value) | Future<void> | Writes the global notifications toggle to SharedPreferences. |
Reminders
Reminders
Stores structured
ReminderSettings (break frequency, daily exercise hour, work hours, night silence window) as a JSON string.| Method | Return type | Description |
|---|---|---|
getReminderSettings() | ReminderSettings | Decodes the stored JSON string and returns a ReminderSettings object, or ReminderSettings.defaults() if nothing is stored yet. |
saveReminderSettings(ReminderSettings settings) | Future<void> | JSON-encodes the settings and writes the string to SharedPreferences. |
Accessibility
Accessibility
Stores
AccessibilitySettings (text size scale, colorblind filter toggle) as a JSON string.| Method | Return type | Description |
|---|---|---|
getAccessibilitySettings() | AccessibilitySettings | Decodes the stored JSON string. Delegates to AccessibilitySettings.fromJsonString() which handles null gracefully by returning defaults. |
saveAccessibilitySettings(AccessibilitySettings s) | Future<void> | JSON-encodes the settings and writes them to SharedPreferences. |
Progress
Progress
Tracks how the teacher uses the app over time. All counters are stored as a single
ProgressData JSON blob.| Method | Return type | Description |
|---|---|---|
getProgress() | ProgressData | Decodes the stored JSON or returns ProgressData.empty() on first run. |
saveProgress(ProgressData progress) | Future<void> | JSON-encodes and persists the ProgressData object. |
recordExerciseCompleted() | Future<ProgressData> | Increments exercisesCompleted by 1, stamps lastUsedDate, saves, and returns the updated data. |
recordActiveBreakCompleted() | Future<ProgressData> | Increments activeBreaksCompleted by 1, stamps lastUsedDate, saves, and returns the updated data. |
recordEmotion(String emotionId) | Future<ProgressData> | Increments the count for the given emotion ID inside the emotionsRecorded map, saves, and returns the updated data. |
recordAppOpen() | Future<ProgressData> | Adds today’s date key (yyyy-MM-dd) to the usageDays set, stamps lastUsedDate, saves, and returns the updated data. |
Teacher Profile
Teacher Profile
Stores the teacher’s display name, avatar selection, and whether the profile setup flow has been completed.
| Method / Property | Return type | Description |
|---|---|---|
getProfileName() | String? | Returns the stored display name, or null if not set. |
setProfileName(String name) | Future<void> | Saves the display name string. |
getProfileAvatar() | String? | Returns the stored avatar identifier or asset path, or null if not set. |
setProfileAvatar(String path) | Future<void> | Saves the avatar identifier or asset path. |
getProfileCompleted() | bool | Returns true if the teacher has finished the profile setup flow; defaults to false. |
setProfileCompleted(bool value) | Future<void> | Marks the profile setup as completed or incomplete. |
SharedPreferences Keys
All keys and their corresponding string constants are defined inAppConstants. Complex types (settings objects, progress) are serialized to JSON strings before storage.
| Constant | SharedPreferences key | Type stored | Notes |
|---|---|---|---|
keyLanguage | 'language' | String | 'es' or 'qu' |
keyThemeMode | 'theme_mode' | String | One of the theme value constants below |
keyNotificationsEnabled | 'notifications_enabled' | bool | Global on/off |
keyReminders | 'reminders' | String (JSON) | Serialized ReminderSettings |
keyAccessibility | 'accessibility' | String (JSON) | Serialized AccessibilitySettings |
keyProgress | 'progress' | String (JSON) | Serialized ProgressData |
keyProfileName | 'profile_name' | String | Teacher display name |
keyProfileAvatar | 'profile_avatar' | String | Avatar asset path or identifier |
keyProfileCompleted | 'profile_completed' | bool | Profile setup flag |
themeLight | 'light' | — | Value written for ThemeMode.light |
themeDark | 'dark' | — | Value written for ThemeMode.dark |
themeSystem | 'system' | — | Value written for ThemeMode.system |
StorageService stores only primitive types (
String, bool, int) and JSON-encoded strings. No binary data, images, or audio files are stored through this service.