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] get current brightness gets 2.8 #1

Closed abdelaziz-mahdy closed 2 years ago

abdelaziz-mahdy commented 3 years ago

I/flutter (23765): RangeError: Invalid value: Not in inclusive range 0..1: 2.8392157554626465 I/flutter (23765): Failed to get current brightness

this happened when testing on pocophone f1 (and has android 10- Miui 12.0.3)

aaassseee commented 3 years ago

May you test is this work for you with:

  screen_brightness:
    git:
      url: https://github.com/aaassseee/screen_brightness
      ref: feature/support_miui
abdelaziz-mahdy commented 3 years ago

thank you I don't get the error anymore now

is there a way to listen for device brightness changes?

and don't know if that was intended or not, but when the brightness is changed in the app it ignores the device brightness (cant change brightness of the screen)

for example if I wanted to change volume of the device It changes the inside and outside the app (global on all of the device) is there is a way to make brightness global?

aaassseee commented 3 years ago

If you are talking about the behavior of changing the brightness will not affect the system setting. That's true. Because there ain't any ways to change setting on iOS.

If you hoping for changing the system settings with screen brightness on Android. That is a different way to implement. Users needs to provide the permission of writing setting. Moreover, it can't find the initial value because you are overriding system setting value instead of application level brightness value.

If you really need that, I can write a function which will only work on Android.

aaassseee commented 3 years ago

If you are talking about the initial brightness won't change when the application in background mode and user changed the system brightness.

I am working on the solution with the initial brightness that stored in the plugin didn't updated when user change. Monitoring initial brightness changes on Android isn't very complicated. However in iOS that would be a challenge.

aaassseee commented 3 years ago

Version 0.0.4 is out. You can update it in with fixing this issue

abdelaziz-mahdy commented 3 years ago

Thanks will update to it

And for the global value I thought it will be better for the value to be local to avoid messing with the user brightness in another applications

aaassseee commented 3 years ago

Do you mean you are satisfied with current flow?

abdelaziz-mahdy commented 3 years ago

yes since i found out that popular apps do it the same way like mxplayer

when ever the user exists the videoPlayer the brightness goes back to system

aaassseee commented 3 years ago

OK, thanks again for reporting this issue. I am closing it, feel free to reopen this issue if you have further problems on Miui

cnting commented 3 years ago

Version 0.1.1 still has this issue on OnePlus and MiUi

aaassseee commented 3 years ago

Hi @cnting, could you post the error log for further studies?

aaassseee commented 3 years ago

And what device model are you using when you get this error?

cnting commented 3 years ago

error log: ` RangeError: Invalid value: Not in inclusive range 0..1: 2.2941176891326904

0 ScreenBrightness.current (package:screen_brightness/src/brightness.dart:75)

`

bug report from umeng: (1)ONEPLUS A6000 with Android10 (2)Redmi with Android11

aaassseee commented 2 years ago

Hi @cnting, Would like to do me a favour. Use another feature branch to test is it working with your phones. Because I didn't have any ONEPLUS or Redmi.

  screen_brightness:
    git:
      url: https://github.com/aaassseee/screen_brightness
      ref: feature/maximum_brightness_with_power_manager
cnting commented 2 years ago

Sorry,the bug is report from umeng,I can't test

aaassseee commented 2 years ago

I had borrowed my coworker's phone which is ONEPLUS A6003. And I have confirmed that this issue has been solved by different approach on getting maximum brightness

aaassseee commented 2 years ago

Please update to the latest version. If there are any problem, feel free to reopen this issue again