setApplicationScreenBrightness method
Set application screen brightness with double value.
The value should be within 0.0 - 1.0. Otherwise, RangeError.range will be throw.
This method is useful for user to change application screen brightness.
When _channel.invokeMethod
fails to set application screen brightness,
it throws PlatformException with code and message:
Code: -1, Message: Unable to change application screen brightness Failed to set brightness
Code: -2, Message: Unexpected error on null brightness Cannot read parameter from method channel map, or parameter is null
(Android only) Code: -10, Message: Unexpected error on activity binding Unexpected error when getting activity, activity may be null
Implementation
@override
Future<void> setApplicationScreenBrightness(double brightness) async {
if (!brightness.isInRange(minBrightness, maxBrightness)) {
throw RangeError.range(brightness, minBrightness, maxBrightness);
}
await pluginMethodChannel.invokeMethod(
methodNameSetApplicationScreenBrightness, {"brightness": brightness});
}