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.

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

final storage = await StorageService.init();
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

Controls the active UI language ('es' for Spanish or 'qu' for Kichwa).
Method / PropertyReturn typeDescription
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.
hasLanguageboolReturns true if a language has been saved (i.e. getLanguage() != null).
Stores the user’s preferred ThemeMode so the app restores it on next launch.
MethodReturn typeDescription
getThemeMode()ThemeModeReads 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.
Global on/off switch for all local notifications.
Method / PropertyReturn typeDescription
notificationsEnabledboolReturns the stored value, defaulting to true when no value has been set.
setNotificationsEnabled(bool value)Future<void>Writes the global notifications toggle to SharedPreferences.
Stores structured ReminderSettings (break frequency, daily exercise hour, work hours, night silence window) as a JSON string.
MethodReturn typeDescription
getReminderSettings()ReminderSettingsDecodes 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.
Stores AccessibilitySettings (text size scale, colorblind filter toggle) as a JSON string.
MethodReturn typeDescription
getAccessibilitySettings()AccessibilitySettingsDecodes 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.
Tracks how the teacher uses the app over time. All counters are stored as a single ProgressData JSON blob.
MethodReturn typeDescription
getProgress()ProgressDataDecodes 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.
Stores the teacher’s display name, avatar selection, and whether the profile setup flow has been completed.
Method / PropertyReturn typeDescription
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()boolReturns 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 in AppConstants. Complex types (settings objects, progress) are serialized to JSON strings before storage.
ConstantSharedPreferences keyType storedNotes
keyLanguage'language'String'es' or 'qu'
keyThemeMode'theme_mode'StringOne of the theme value constants below
keyNotificationsEnabled'notifications_enabled'boolGlobal on/off
keyReminders'reminders'String (JSON)Serialized ReminderSettings
keyAccessibility'accessibility'String (JSON)Serialized AccessibilitySettings
keyProgress'progress'String (JSON)Serialized ProgressData
keyProfileName'profile_name'StringTeacher display name
keyProfileAvatar'profile_avatar'StringAvatar asset path or identifier
keyProfileCompleted'profile_completed'boolProfile 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.

Build docs developers (and LLMs) love