battery 1.0.11 copy "battery: ^1.0.11" to clipboard
battery: ^1.0.11 copied to clipboard

discontinuedreplaced by: battery_plus
outdated

Flutter plugin for accessing information about the battery state (full, charging, discharging) on Android and iOS.

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
});
267
likes
30
points
17.3k
downloads

Publisher

verified publisherflutter.dev

Weekly Downloads

Flutter plugin for accessing information about the battery state (full, charging, discharging) on Android and iOS.

License

BSD-3-Clause (license)

Dependencies

battery_platform_interface, flutter, meta

More

Packages that depend on battery