tree: ea644998a421709ab8d44eabe2123bd8b67779c9 [path history] [tgz]
  1. android/
  2. example/
  3. integration_test/
  4. ios/
  5. lib/
  6. test/
  7. CHANGELOG.md
  8. LICENSE
  9. pubspec.yaml
  10. README.md
packages/battery/battery/README.md

Battery

pub package

A Flutter plugin to access various information about the battery of the device the app is running on.

Usage

To use this plugin, add battery as a dependency in your pubspec.yaml file.

Example

// Import package
import 'package:battery/battery.dart';

// Instantiate it
var _battery = Battery();

// Access current battery level
print(await _battery.batteryLevel);

// Be informed when the state (full, charging, discharging) changes
_battery.onBatteryStateChanged.listen((BatteryState state) {
  // Do something with new state
});