system property

  1. @override
Future<double> get system
override

Returns system screen brightness which is set when application is started.

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

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

Platform difference: (macOS): return initial brightness

When _channel.invokeMethod fails to get current 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;
}