-
Notifications
You must be signed in to change notification settings - Fork 0
Utilities
Shared widgets live in lib/widgets/. They keep feature modules focused on their own behaviour and prevent UI duplication.
- Buttons:
app_button.dart,custom_button.dart, andapp_icon_button.dart - Search:
app_search_bar.dart - Controls:
app_segmented_triple_control.dartandscroll_to_top_button.dart - Feedback:
confirm_dialog.dartanderror_message.dart - Camera preview:
inline_camera_preview.dart
Keep a widget inside its feature module when it is used only by that feature; move it to lib/widgets/ only once it represents a reusable app-wide component.
lib/core/ contains application-wide services and wiring:
-
injection.dartregisters dependencies with GetIt before the app starts. -
app_scope.dartexposesAppServicesandSettingsControllerto widgets. -
app_services.dartis the aggregate of UI-facing feature services. -
settings.dart,locale_service.dart, andunit_preferences.dartprovide persisted preferences, locale resolution, and temperature formatting. -
themes.dartdefines the app's light and dark themes.
Widgets access dependencies through AppScope.of(context) rather than directly through GetIt. This keeps the service locator outside presentation code and centralizes feature wiring in injection.dart.
For the full structure and dependency direction, see Architecture.
OpenPlants uses Flutter's built-in gen-l10n system with ARB files.
assets/l10n/l10n_en.arbassets/l10n/l10n_de.arb
Configuration lives in l10n.yaml; generated output is written to lib/l10n/.
Use the BuildContext extension from lib/l10n/l10n_x.dart:
Text(context.l10n.appTitle)- Add the key to every supported locale in
assets/l10n/. - Run
fvm flutter gen-l10nto regeneratelib/l10n/. - Use the new key via
context.l10n.<key>.
LocaleService applies an explicit user choice when supported, otherwise uses the device locale and falls back to English. Keep the ARB files aligned so that every supported locale has each key.
OpenPlants persists user preferences in shared_preferences as JSON.
SettingsController in lib/core/settings.dart loads settings once at startup and writes changes asynchronously.
The Settings model includes:
- theme mode flags;
- text-scaling preference;
- onboarding completion flag (
didCompleteOnboarding); - selected language (
localeCode) ornullfor the system language; and - temperature unit (Celsius or Fahrenheit).
JSON keeps settings backwards-compatible: add a new field with a default in Settings.fromJson(...) so existing installations can load it safely.