'Flutter How can i check Battery Health
I want to check device Battery Health using Flutter the plugin Battery and the documentation didn't give any in formation about battery health it only shows you the battery state charging or not and battery level but didn't give you the health I mean goog bad something like this and Thankyou. https://pub.dev/packages/battery and this package wasn't able to help me
Solution 1:[1]
As other solutions are mostly discontinued, I figured I might post a new one.
From the link page: https://pub.dev/packages/battery_info
// Import package
import 'package:battery/battery_info.dart';
import 'package:battery_info/model/android_battery_info.dart';
import 'package:battery_info/enums/charging_status.dart';
import 'package:battery_info/model/iso_battery_info.dart';
// Access current battery health - Android
print("Battery Health: ${(await BatteryInfoPlugin().androidBatteryInfo).health}");
// Access current battery level - IOS
print("Battery Level: ${(await BatteryInfoPlugin().iosBatteryInfo).batteryLevel}");
// Calculate estimated charging time
BatteryInfoPlugin().androidBatteryInfoStream.listen((AndroidBatteryInfo batteryInfo) {
print("Charge time remaining: ${(batteryInfo.chargeTimeRemaining / 1000 / 60).truncate()} minutes");
});
Solution 2:[2]
// Instantiate it
var battery = Battery();
// Access current battery level
var batteryPercentage = await battery.batteryLevel;
Solution 3:[3]
I am still searching for ios devices but there is a flutter package for android devices to get the battery health
import 'package:android_device_info/android_device_info.dart';
var batteryInfo = await AndroidDeviceInfo().getBatteryInfo();
print(batteryInfo);
Refer to the pub.dev link: android_device_info
Solution 4:[4]
Its very simple dude.
Just Try this: https://pub.dev/packages/battery_info
It provides all information on the battery including its health, charging status, remaining charge time, etc. However, there are few limitations on IOS due to Apple restrictions, so you can only get battery percentage and status on Apple devices.
Solution 5:[5]
You can try out https://pub.dev/packages/battery_info, it provides more detailed information on battery such as health, charging status, remaining charge time. However, there are some limitations on IOS due to Apple restrictions, so you can only get battery percentage and status on Apple devices.
You can also subscribe to a stream instead of just fetching future, so you could get life update on remaining charge time for example.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Daniele De Vincenti |
| Solution 2 | |
| Solution 3 | Hari Krishna Bikki |
| Solution 4 | Jaimin Modi |
| Solution 5 | Dharman |
