screen_brightness 0.0.4 copy "screen_brightness: ^0.0.4" to clipboard
screen_brightness: ^0.0.4 copied to clipboard

outdated

A Plugin for controlling screen brightness with application life cycle set and reset brightness implemented

screen_brightness #

A Plugin for controlling screen brightness with application life cycle set and reset brightness implemented

Getting Started #

Install #

Add the following lines in your pubspec.yaml file

  screen_brightness: ^latest_version

latest_version:
pub package

API #

Initial brightness

Future<double> get initialBrightness async {
  try {
    return await ScreenBrightness.initial;
  } catch (e) {
    print(e);
    throw 'Failed to get initial brightness';
  }
}

Current brightness

Future<double> get currentBrightness async {
  try {
    return await ScreenBrightness.current;
  } catch (e) {
    print(e);
    throw 'Failed to get current brightness';
  }
}

Set brightness

Future<void> setBrightness(double brightness) async {
  try {
    await ScreenBrightness.setScreenBrightness(brightness);
  } catch (e) {
    print(e);
    throw 'Failed to set brightness';
  }
}

reset brightness

Future<void> resetBrightness() async {
  try {
    await ScreenBrightness.resetScreenBrightness();
  } catch (e) {
    print(e);
    throw 'Failed to reset brightness';
  }
}

Usage #

  • DON'T use didChangeAppLifecycleState to set or reset brightness because this plugin already implemented this function.
  • You may also use this plugin with wakelock to prevent screen sleep

Maintainer #

Jack Liu

99
likes
0
pub points
98%
popularity

Publisher

unverified uploader

A Plugin for controlling screen brightness with application life cycle set and reset brightness implemented

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on screen_brightness