system property

  1. @override
Future<double> get system
override

Returns system screen brightness.

The value should be within 0.0 - 1.0. Otherwise, RangeError.range will be throw.

This parameter is useful for user to get system screen brightness value after calling setSystemScreenBrightness

This parameter is useful for user to get system screen brightness value after calling resetApplicationScreenBrightness

Platform difference: (macOS)(Windows): return initial brightness

When _channel.invokeMethod fails to get system screen brightness, it throws PlatformException with code and message:

Code: -9, Message: value returns null

Implementation

@override
Future<double> get system async {
  final systemBrightness = await pluginMethodChannel
      .invokeMethod<double>(methodNameGetSystemScreenBrightness);
  if (systemBrightness == null) {
    throw PlatformException(code: "-9", message: "value returns null");
  }

  if (!systemBrightness.isInRange(minBrightness, maxBrightness)) {
    throw RangeError.range(systemBrightness, minBrightness, maxBrightness);
  }

  return systemBrightness;
}