ErgoKawsay manages global UI state with threeDocumentation 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.
ChangeNotifier controllers wired at the app root in app.dart. Each controller owns one slice of global state, reads its persisted value from StorageService on construction, and notifies listeners when the user changes a preference. State is propagated through the widget tree via custom InheritedWidget scope classes — no external state management library is involved. All three controllers are instantiated in _ErgoKawsayAppState.initState() and disposed in dispose(), so their lifetimes match the widget tree.
Controllers Overview
LocaleController
Manages the active
Locale. Switches between Spanish (es) and Kichwa
(qu) and persists the choice via StorageService.ThemeController
Manages
ThemeMode (light / dark / system). Persists the user’s
preference and rebuilds MaterialApp on change.AccessibilityController
Manages
AccessibilitySettings — text size scale and colour-blind
filter. Applied globally via MediaQuery and ColorFiltered.LocaleController
File:lib/core/localization/locale_controller.dart
| Member | Description |
|---|---|
locale | Returns the current Locale constructed from the persisted language code ('es' or 'qu') |
updateLanguage(String code) | Persists code via StorageService and triggers a rebuild of MaterialApp |
LocaleController is exposed to the subtree via the LocaleControllerScope InheritedWidget:
LocaleControllerScope.of(context) anywhere in the tree to obtain the controller.
ThemeController
File:lib/core/localization/theme_controller.dart
| Member | Description |
|---|---|
themeMode | Returns the current ThemeMode from StorageService (light, dark, or system) |
setThemeMode(ThemeMode) | Persists the selection via StorageService and notifies listeners |
ThemeControllerScope:
AppConstants.themeLight, AppConstants.themeDark, and AppConstants.themeSystem.
AccessibilityController
File:lib/core/localization/accessibility_controller.dart
| Member | Description |
|---|---|
settings | Returns the current AccessibilitySettings from StorageService |
updateSettings(AccessibilitySettings) | Serialises the settings to JSON, persists them, and notifies |
AccessibilityControllerScope:
App Builder
_ErgoKawsayAppState.build() wraps the entire widget tree in four nested scope widgets and a single ListenableBuilder that merges all three controllers into one listenable. This means any change to locale, theme, or accessibility causes exactly one MaterialApp rebuild:
The colour-blind filter applies a deuteranopia simulation matrix via
ColorFilter.matrix. It is wrapped around the entire child subtree so that
every pixel rendered by MaterialApp is filtered uniformly. The
text scale overrides the system MediaQuery text scaler so that the
user’s in-app size preference always takes precedence over OS-level scaling.StorageServiceScope
StorageServiceScope is an InheritedWidget that makes the single StorageService instance available anywhere in the widget tree without passing it down manually through constructors:
_ErgoKawsayAppState.build(), so every screen and controller can call StorageServiceScope.of(context) to read or write persisted data.
Usage Pattern
Access a controller from any widget that is a descendant of the app root:Kichwa Locale Workaround
Kichwa (qu) is not included in flutter_localizations, so Flutter’s
GlobalMaterialLocalizations.delegate and GlobalWidgetsLocalizations.delegate
skip it. Without a fallback, Material components like dialogs, date pickers, and
time pickers would throw a missing-localizations assertion at runtime.
ErgoKawsay solves this with two custom delegates declared in app.dart:
localizationsDelegates so they win the first-match resolution for the qu locale:
localeResolutionCallback is overridden to always return the controller’s locale, bypassing Flutter’s default locale negotiation algorithm entirely: