-
Notifications
You must be signed in to change notification settings - Fork 0
Architecture
OpenPlants is a Flutter plant companion app organised around a lightweight Clean Architecture. It avoids a BLoC layer: feature pages keep local presentation state, while shared application state is supplied through AppScope.
-
lib/core/— application wiring, settings, localization and formatting services, themes, and shared failures. -
lib/pages/— feature modules, including collection management, care scheduling, diagnosis, journals, identification, and species data. -
lib/widgets/— reusable UI components shared by features. -
assets/l10n/— source ARB localization files; generated Dart output is inlib/l10n/. -
assets/ml/plant-identification/andassets/species/— bundled identification and species-reference assets.
Feature modules normally follow this dependency direction:
Page → UseCases → Repository → DataSource
-
*_page.dartrenders the feature and handles local widget state. -
*_usecases.dartcoordinates feature behaviour. -
*_repository.dartexposes domain-oriented operations. -
*_datasource.dartowns external or persisted data access. - Entity and value files model feature data.
Some larger features include focused helpers, such as the care-schedule engine and modifiers, the diagnosis engine, or the plant-identification classifier pipeline. Keep those details inside the owning feature rather than leaking them into pages.
main() calls init() in lib/core/injection.dart before runApp(). The initializer loads SettingsController and registers feature data sources, repositories, use cases, and supporting services with GetIt.
AppServices groups the UI-facing feature services. AppScope, an InheritedWidget, makes both AppServices and SettingsController available to the widget tree:
final services = AppScope.of(context).services;
final settings = AppScope.of(context).settings;Pages must use AppScope rather than importing the GetIt container directly. This keeps service lookup at the application boundary and makes dependencies explicit in feature wiring.
-
SettingsControlleris the single source of truth for persisted user preferences. -
LocaleServiceresolves an explicit language selection, then the system locale, and finally English as a fallback. -
TemperatureFormatterformats Celsius input in the user-selected unit and active locale. -
OpenPlantsApprebuildsMaterialAppwhen settings or the locale service changes, applying theme, locale, and text-scaling preferences.