flutter_screen
flutter_screen copied to clipboard
Reset user brightness / Turn off plugin
It might be related to this comment: https://github.com/clovisnicolas/flutter_screen/issues/8#issuecomment-487923284
It would be great to have a way to reset the user brightness, but more like turning off the plugin.
This is because (as the related comment says) it becomes impossible to manually change the brightness.
// on initState, get original brightness.
_userBrightnessRatio = await Screen.brightness;
...
// This correctly sets the original brightness back, but
// there is no way to change it using the user preferences.
// You need to close the app to be able to change it.
Screen.setBrightness(_userBrightnessRatio);
Do you believe there is a way to do this? I thought of adding the proper method to the https://github.com/clovisnicolas/flutter_screen/blob/master/android/src/main/java/flutter/plugins/screen/screen/ScreenPlugin.java file. I would be willing to create a PR if we could find a solution 😁.
Please someone work on this. I can't do the iOS part and I also can't find the solution for it, perhaps the problem does not even exist on iOS? On Android, you can set the brightness to BRIGHTNESS_OVERRIDE_NONE (which is -1.0f), and that will disable the override.
https://github.com/clovisnicolas/flutter_screen/pull/17 please see this PR @Pikaju
@singlakaran I'm not the owner of this repository so I can't merge
It might be related to this comment: #8 (comment)
It would be great to have a way to reset the user brightness, but more like turning off the plugin.
This is because (as the related comment says) it becomes impossible to manually change the brightness.
// on initState, get original brightness. _userBrightnessRatio = await Screen.brightness; ... // This correctly sets the original brightness back, but // there is no way to change it using the user preferences. // You need to close the app to be able to change it. Screen.setBrightness(_userBrightnessRatio);
Do you believe there is a way to do this? I thought of adding the proper method to the https://github.com/clovisnicolas/flutter_screen/blob/master/android/src/main/java/flutter/plugins/screen/screen/ScreenPlugin.java file. I would be willing to create a PR if we could find a solution 😁.
This solution works for resetting on iOS, but on Android reset using BRIGHTNESS_OVERRIDE_NONE (which is -1)