aaassseee / screen_brightness

A Plugin for controlling screen brightness with application life cycle set and reset brightness implemented
https://pub.dev/packages/screen_brightness
MIT License
25 stars 22 forks source link

[bug] On iOS, screen brightness will always restore to initial brightness when app pauses #2

Closed singularity-s0 closed 3 years ago

singularity-s0 commented 3 years ago

The plugin should not alter screen brightness unless explicitly instructed to do so.

However, the plugin has a bug in lifecycle handling that causes the app to always reset the brightness to the initial state when it is about to be paused, even when no method of the plugin has ever been called.

Reproduce:

  1. Create a minimal project and add this as a plugin in Pubspec.yaml, don’t modify other code. Compile and run
  2. Quit app
  3. Set Brightness to minimum via Control Center
  4. Launch app
  5. Set Brightness to maximum via Control Center
  6. Return to Home Screen -> brightness changes to minimum, which is unexpected

EDIT: Also, the Reset Brightness function always resets the brightness to the state when the application was initially launched. However, an iOS app might stay in background for a long time and the brightness has probably changed since then. We might want to update originalBrightness when calling setBrightness() or when the application resumes from background.

aaassseee commented 3 years ago

Thanks for the bug report. I will take a look at it.

aaassseee commented 3 years ago

issue might be fixed on 0.1.0 if you have any question feel free to reopen it