The app uses Flutter's localization system with ARB files and the intl_utils package for code generation. The generated S class provides two access patterns:
S.maybeOf(context) / S.of(context) - Creates InheritedWidget dependency, triggers rebuilds on locale changeS.current - Returns the last loaded instance, NO rebuild dependencyA global gStrings getter was introduced as a convenience accessor that uses S.current, inadvertently bypassing Flutter's reactive localization system in 364 places across 57 files.
| Context | Pattern | Rationale |
|---------|---------|-----------|
| Widgets/Views with BuildContext | context.strings | Reactive, triggers rebuilds |
| Enums needing labels | String label(S strings) | Caller provides reactive strings |
| Forms with validators | S get _strings => context?.strings ?? S.current | Forms have context available |
| Services returning TurboResponse | S.current | Error messages reflect locale at capture time |
| DTOs with placeholder factories | factory X.loading({required S strings}) | Caller provides reactive strings |
| RandomService | method({required BuildContext context}) | Service methods receive context |
| ViewModels | context.strings (remove fallback) | ViewModels have context access |
Alternatives Considered:
Services that return TurboResponse.fail() capture error messages at the moment the error occurs. Using S.current is acceptable because:
The following files are stale duplicates that should be deleted:
lib/l10n/l10n.dart - Partial copy of lib/generated/l10n.dart, only supports Englishlib/l10n/intl/messages_all.dart - Stale message loaderlib/l10n/intl/messages_en.dart - Stale English messagesThe canonical generated files are in lib/generated/.
| Risk | Mitigation | |------|------------| | Large number of changes (364 usages) | Batch by pattern type, run tests after each batch | | Breaking existing tests | Tests should use same patterns as production code | | Missing edge cases | Comprehensive grep for gStrings after migration |
lib/l10n/globals/g_strings.dartflutter analyze and fix warningsIf issues arise, the gStrings accessor can be temporarily restored. However, this masks the underlying bug and should only be used as emergency fallback.
None - all patterns have been decided during refinement.
Reacties