Fix system brightness setting (#212)
* Use correct brightness when enabling system brightness * Listen to system brightness changes if needed * Use final instead of var
This commit is contained in:
parent
3d250f4e41
commit
0e4dd68b84
|
@ -56,12 +56,24 @@ class _AppState extends State<App> {
|
|||
//TODO: wait until settings is ready?
|
||||
settings.onChange().listen((_) {
|
||||
setState(() {
|
||||
if (!settings.useSystemColors) {
|
||||
if (settings.useSystemColors) {
|
||||
brightness = SchedulerBinding.instance.platformDispatcher.platformBrightness;
|
||||
} else {
|
||||
brightness = settings.darkMode ? Brightness.dark : Brightness.light;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Listen to changes to the system brightness mode, update accordingly
|
||||
final dispatcher = SchedulerBinding.instance.platformDispatcher;
|
||||
dispatcher.onPlatformBrightnessChanged = () {
|
||||
if (settings.useSystemColors) {
|
||||
setState(() {
|
||||
brightness = dispatcher.platformBrightness;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
super.initState();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue