56f0557d94
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>
24 lines
668 B
Dart
24 lines
668 B
Dart
import 'package:flutter/material.dart';
|
|
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});
|
|
|
|
@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: buildLightTheme(),
|
|
darkTheme: buildDarkTheme(),
|
|
themeMode: mode.materialMode,
|
|
routerConfig: router,
|
|
);
|
|
}
|
|
}
|