feat(flutter): MinstrelApp watches themeMode + offers darkTheme
MaterialApp now provides both light and dark themes plus a themeMode bound to themeModeProvider. ThemeMode.system rebuilds the tree automatically when the OS toggles brightness — no manual listener needed. While themeModeProvider is loading (storage read in flight), falls back to AppThemeMode.system, which inherits the OS setting. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -3,6 +3,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
import 'shared/routing.dart';
|
||||
import 'theme/theme_data.dart';
|
||||
import 'theme/theme_mode_provider.dart';
|
||||
|
||||
class MinstrelApp extends ConsumerWidget {
|
||||
const MinstrelApp({super.key});
|
||||
@@ -10,9 +11,12 @@ class MinstrelApp extends ConsumerWidget {
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final router = ref.watch(routerProvider);
|
||||
final mode = ref.watch(themeModeProvider).value ?? AppThemeMode.system;
|
||||
return MaterialApp.router(
|
||||
title: 'Minstrel',
|
||||
theme: buildThemeData(),
|
||||
theme: buildLightTheme(),
|
||||
darkTheme: buildDarkTheme(),
|
||||
themeMode: mode.materialMode,
|
||||
routerConfig: router,
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user