tree: 9cc6e6f3d92945ea33d1dcecd5b4027d566a6f35 [path history] [tgz]
  1. android/
  2. example/
  3. ios/
  4. lib/
  5. test/
  6. CHANGELOG.md
  7. LICENSE
  8. pubspec.yaml
  9. README.md
packages/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
});