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

discontinued
PlatformAndroidiOS

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

Battery #


Deprecation Notice #

This plugin has been replaced by the Flutter Community Plus Plugins version, battery_plus. No further updates are planned to this plugin, and we encourage all users to migrate to the Plus version.

Critical fixes (e.g., for any security incidents) will be provided through the end of 2021, at which point this package will be marked as discontinued.


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
});
268
likes
150
pub points
94%
popularity

Publisher

verified publisherflutter.dev

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

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

battery_platform_interface, flutter, meta

More

Packages that depend on battery