application property
Returns application screen brightness value.
The value should be within 0.0 - 1.0. Otherwise, RangeError.range will be throw.
This parameter is useful for user to get application screen brightness value after calling setApplicationScreenBrightness
Calling this method after calling resetApplicationScreenBrightness may return wrong value in iOS because UIScreen.main.brightness returns old brightness value
When _channel.invokeMethod
fails to get application screen brightness,
it throws PlatformException with code and message:
Code: -9, Message: value returns null
(Android only) Code: -10, Message: Unexpected error on activity binding Unexpected error when getting activity, activity may be null
(Android only) (macOS only) Code: -11, Message: Could not found system screen brightness value Unexpected error when getting brightness from Setting using (Android) Settings.System.SCREEN_BRIGHTNESS
Implementation
@override
Future<double> get application async {
final currentBrightness = await pluginMethodChannel
.invokeMethod<double>(methodNameGetApplicationScreenBrightness);
if (currentBrightness == null) {
throw PlatformException(code: "-9", message: "value returns null");
}
if (!currentBrightness.isInRange(minBrightness, maxBrightness)) {
throw RangeError.range(currentBrightness, minBrightness, maxBrightness);
}
return currentBrightness;
}