large Flutter Favorite logosmall Flutter Favorite logo

battery_plus 2.1.4 icon indicating copy to clipboard operation
battery_plus: ^2.1.4 copied to clipboard

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

Battery Plus #

Flutter Community: battery_plus

pub package battery_plus

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

Platform Support #


Usage #

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

Example #

// Import package
import 'package:battery_plus/battery_plus.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

Important: As of January 2021, the Flutter team is no longer accepting non-critical PRs for the original set of plugins in flutter/plugins, and instead they should be submitted in this project. You can read more about this announcement here. as well as in the Flutter 2 announcement blog post.