diff options
| author | Paul Buetow <paul@buetow.org> | 2026-05-22 09:34:24 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-05-22 09:34:24 +0300 |
| commit | bcf89f586c6dd80f240ac3fb80d01ee3c5f6bcd0 (patch) | |
| tree | 594f10487ad313790798531863788b001dd662f2 /player-android/lib/main.dart | |
| parent | cce598d8b698ecf4490127d5fad9bd0995ec1050 (diff) | |
Fix Material 3 theming review issues (task fb)
- Roll back ThemeNotifier state on SharedPreferences write failure so
in-memory and disk never diverge
- Fix stale comment: scaffoldBackgroundColor ← --bg-body (not background)
- Fix source attribution: theme.css not docs/theming.md
- Make _ThemeToggle const-constructible; remove incorrect ignore comment
- Inline _buildSegmentedButton into _ThemeToggle.build (was a trivial passthrough)
- Add defensive isNotEmpty comment on SegmentedButton.onSelectionChanged
- Hoist buildLightTheme()/buildDarkTheme() to module-level finals in main.dart
so ThemeData is built once at startup rather than on every rebuild
- Add _ThemeToggle tests: initial segment selection and segment tap dispatch
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'player-android/lib/main.dart')
| -rw-r--r-- | player-android/lib/main.dart | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/player-android/lib/main.dart b/player-android/lib/main.dart index 2c1b193..3358383 100644 --- a/player-android/lib/main.dart +++ b/player-android/lib/main.dart @@ -64,6 +64,16 @@ void main() async { } // --------------------------------------------------------------------------- +// Module-level theme constants +// --------------------------------------------------------------------------- + +// Built once at startup rather than on every rebuild of PlayerAndroidApp. +// ThemeData construction is not cheap, and the colour tokens never change +// at runtime — only the active ThemeMode (light/dark/system) does. +final _lightTheme = buildLightTheme(); +final _darkTheme = buildDarkTheme(); + +// --------------------------------------------------------------------------- // Root widget // --------------------------------------------------------------------------- @@ -92,8 +102,8 @@ class PlayerAndroidApp extends ConsumerWidget { title: 'Player', routerConfig: router, // Material 3 is enabled in both ThemeData instances; see theme_provider.dart. - theme: buildLightTheme(), - darkTheme: buildDarkTheme(), + theme: _lightTheme, + darkTheme: _darkTheme, themeMode: themeMode, ); } |
