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

[feat] Update docs to mention Android permission requirement #35

Closed CillianMyles closed 1 month ago

CillianMyles commented 1 month ago

Description (What is the problem)

Upgraded to 2.0.0+1 to try out the system brightness (thanks for adding that 🙏), and for Android I got an error logged when first trying to change the system brightness:

E/flutter ( 1332): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(-1, Unable to change system screen brightness, null, null)
E/flutter ( 1332): #0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:648:7)
E/flutter ( 1332): #1      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:334:18)
E/flutter ( 1332): <asynchronous suspension>
E/flutter ( 1332): #2      MethodChannelScreenBrightness.setSystemScreenBrightness (package:screen_brightness_platform_interface/method_channel_screen_brightness.dart:76:5)
E/flutter ( 1332): <asynchronous suspension>
E/flutter ( 1332): #3      PlayerController.setBrightness (package:faradaysounds/src/player/player_controller.dart:202:5)
E/flutter ( 1332): <asynchronous suspension>

And a native Android settings screen popped up:

I checked the PR (https://github.com/aaassseee/screen_brightness/pull/34) which introduced the system brightness change and saw that a permission was added to the Android part of the example app. After adding that same permission to my own app, I was able to accept the `Allow modifying system settings` and then could change the system brightness successfully. ### Solution suggestion Add a note about the permission to the README so others can skip this issue.

aaassseee commented 1 month ago

Hi @CillianMyles. Thanks for the suggestion. I will update the README file this week.

CillianMyles commented 1 month ago

Hi @CillianMyles. Thanks for the suggestion. I will update the README file this week.

I made a stab at it https://github.com/aaassseee/screen_brightness/pull/37