refactor(theme): provide ThemeSettings as an inherited value, out of AppState#1444
Merged
Conversation
b3bd334 to
5f97b55
Compare
digiboridev
approved these changes
Jun 24, 2026
…AppState The active theme settings were static for a whole run (seeded from AppThemes, never changed at runtime) yet lived in AppState, and the only thing that ever emitted AppThemeSettingsChanged was external. Move the theme settings out of the bloc and provide them as an inherited value at the composition root, so the app consumes them directly via the widget tree - the same pattern already used for FeatureAccess. - RootApp provides Provider<ThemeSettings>, derived directly from the registry's AppThemes (standalone: the first bootstrap-built theme). A future embedder can override this provider to drive the theme. - App.build and ThemeModeScreen read context.watch<ThemeSettings>() instead of AppState.themeSettings. - isThemeModeSupported / effectiveThemeMode move from AppState getters to a ThemeSettings extension (they depend only on the settings plus the mode). - AppState keeps only themeMode (still user-switchable and persisted); drop the themeSettings field, AppThemeSettingsChanged event and its handler, and the now-unused AppThemes dependency of AppBloc. - Drop the widget-tree Provider<AppThemes>: it was consumed only to seed the theme, so ThemeSettings now reads AppThemes straight from the registry. Standalone behaviour is unchanged. Prepares the app for host-driven theming.
5f97b55 to
e8f8c50
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
Moves the active
ThemeSettingsout ofAppStateand provides it as an inherited value at the composition root, so the app consumes it directly through the widget tree — the same pattern already used forFeatureAccess.The theme settings were static for a whole run (seeded once from
AppThemes, never changed at runtime), yet lived inAppState; the only code that ever emittedAppThemeSettingsChangedwas external. This refactor makesRootAppthe single injection boundary for the theme and keeps everything below it consuming via providers — no bloc relay.This is groundwork for host-driven theming (an embedder overriding the provider); standalone behaviour is unchanged.
Changes
RootAppprovidesProvider<ThemeSettings>(standalone:AppThemes.values.first.settings). An embedder can override this provider to drive the theme.App.buildandThemeModeScreenreadcontext.watch<ThemeSettings>()instead ofAppState.themeSettings.isThemeModeSupported/effectiveThemeModemove fromAppStategetters to aThemeSettingsextension (they depend only on the settings plus the mode).AppStatekeeps onlythemeMode(still user-switchable and persisted). Dropped: thethemeSettingsfield, theAppThemeSettingsChangedevent + handler, and the now-unusedAppThemesdependency ofAppBloc.Verification
flutter analyze— clean.ThemeProvider.ofconsumers (e.g.themed_scaffold) unaffected — theThemeProviderwidget still wrapsMaterialApp.