android_battery_level_plus 0.0.2
android_battery_level_plus: ^0.0.2 copied to clipboard
A Flutter plugin to access the device's current battery level on Android.
android_battery_level_plus #
A Flutter plugin to access the device's current battery level on Android.
Features #
- Get the current battery percentage of the Android device.
- Easy-to-use API via Method Channels.
- Lightweight and efficient.
Platform Support #
| Platform | Support |
|---|---|
| Android | SDK 24+ |
Installation #
Add android_battery_level_plus to your pubspec.yaml:
dependencies:
android_battery_level_plus: ^0.0.1
Usage #
Import the package:
import 'package:android_battery_level_plus/battery_plugin.dart';
Create an instance and call getBatteryLevel():
final _batteryPlugin = BatteryPlugin();
Future<void> fetchBattery() async {
try {
int? level = await _batteryPlugin.getBatteryLevel();
print('Battery Level: $level%');
} catch (e) {
print('Failed to get battery level: $e');
}
}
Example #
Check the example directory for a complete sample application.