mirror of
https://github.com/vodemn/m3_lightmeter.git
synced 2024-11-24 00:10:47 +00:00
Update theme_provider.dart
This commit is contained in:
parent
00e104de9b
commit
24977ff852
1 changed files with 14 additions and 1 deletions
|
@ -44,15 +44,28 @@ class ThemeProvider extends StatefulWidget {
|
|||
State<ThemeProvider> createState() => ThemeProviderState();
|
||||
}
|
||||
|
||||
class ThemeProviderState extends State<ThemeProvider> {
|
||||
class ThemeProviderState extends State<ThemeProvider> with WidgetsBindingObserver {
|
||||
UserPreferencesService get _prefs => context.read<UserPreferencesService>();
|
||||
|
||||
late final _themeTypeNotifier = ValueNotifier<ThemeType>(_prefs.themeType);
|
||||
late final _dynamicColorNotifier = ValueNotifier<bool>(_prefs.dynamicColor);
|
||||
late final _primaryColorNotifier = ValueNotifier<Color>(_prefs.primaryColor);
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
WidgetsBinding.instance.addObserver(this);
|
||||
}
|
||||
|
||||
@override
|
||||
void didChangePlatformBrightness() {
|
||||
super.didChangePlatformBrightness();
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
WidgetsBinding.instance.removeObserver(this);
|
||||
_themeTypeNotifier.dispose();
|
||||
_dynamicColorNotifier.dispose();
|
||||
_primaryColorNotifier.dispose();
|
||||
|
|
Loading…
Reference in a new issue