battery_all_ggez
A lightweight, zero-dependency, Dart 3 compatible Flutter plugin designed to extract absolutely every single hardware metric exposed by the Android OS kernel.
Older battery packages fail on modern Dart 3 null-safety restrictions, and generic alternatives restrict you to basic charging states. battery_all_ggez hooks natively into deep Android telemetry interfaces (BatteryManager and Sticky Intent broadcasts) to expose a complete electrical, thermal, and lifecycle blueprint through a clean, unified ClassName.property design syntax.
All Parameters Unlocked)
- Charge Capacity & Fuel Gauges: Calculated Percentage, Raw Register Level, Hardware Raw Scale, Factory Design Size (
mAh), Remaining Microamps (µAh), Remaining Energy (nWh). - Electrical & Thermal Physics: Tension Voltage (Both
Volts&mV), Pack Core Temperature (°C), Instantaneous Current Draw Snap (mA), Smoothed Rolling Average Current (mA). - Chemical & Lifespan Architecture: BMS Structural Safety Health, Lifetime Hardware Charge Cycles (Android 14+), Cell Chemical Composition (e.g., Li-ion), Physical Battery Present Check, System Critical Battery Low Alert flag.
- Operational States & Projections: BMS Charging/Discharging Status, Active Hardware Input Interfaces (AC, USB, Wireless), Real-Time Projection Time Countdown to Full.
Getting Started
Complete Code Integration Sequence (main.dart)
The plugin structure utilizes a clean, boilerplate-free callback architecture. You simply call .refresh() in your widgets and pass setState to rebuild the layout.
import 'package:flutter/material.dart';
import 'package:battery_all_ggez/battery_all_ggez.dart';
void main() => runApp(const MaterialApp(home: BatteryDashboard()));
class BatteryDashboard extends StatefulWidget {
const BatteryDashboard({super.key});
@override
State<BatteryDashboard> createState() => _BatteryDashboardState();
}
class _BatteryDashboardState extends State<BatteryDashboard> {
bool _isLoading = true;
@override
void initState() {
super.initState();
_refreshData();
}
Future<void> _refreshData() async {
// SINGLE LINE INVOKER: Manages layout reload flags and native platform queries simultaneously
await BatteryAllGgez.refresh(
onNotify: () => setState(() {}),
onStateChanged: (loading) => setState(() => _isLoading = loading),
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Battery Core Telemetry'),
actions: [
IconButton(
icon: const Icon(Icons.refresh),
onPressed: _refreshData,
),
],
),
body: _isLoading
? const Center(child: CircularProgressIndicator())
: ListView(
padding: const EdgeInsets.all(16.0),
children: [
ListTile(title: Text("Calculated Charge"), trailing: Text("\${BatteryAllGgez.percentage}%")),
ListTile(title: Text("Core Temperature"), trailing: Text("\${BatteryAllGgez.temperature}°C")),
ListTile(title: Text("Electrical Tension"), trailing: Text("\${BatteryAllGgez.voltage} V")),
ListTile(title: Text("Current Flow Now"), trailing: Text("\${BatteryAllGgez.currentNow} mA")),
ListTile(title: Text("Design Size Limit"), trailing: Text("\${BatteryAllGgez.capacity} mAh")),
ListTile(title: Text("BMS Safety Health"), trailing: Text(BatteryAllGgez.health)),
ListTile(title: Text("Hardware Lifespan Cycles"), trailing: Text("\${BatteryAllGgez.cycleCount}")),
],
),
);
}
}
License
This plugin library is distributed under the open-source MIT License.