battery_all_ggez 1.0.2 copy "battery_all_ggez: ^1.0.2" to clipboard
battery_all_ggez: ^1.0.2 copied to clipboard

PlatformAndroid

A new Flutter plugin to access all battery information in an ez way.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:battery_all_ggez/battery_all_ggez.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  bool _isLoading = true;

  @override
  void initState() {
    super.initState();
    // Initialize cleanly on boot up using your static plugin method
    BatteryAllGgez.refresh(
      onNotify: () => setState(() {}),
      onStateChanged: (loading) => setState(() => _isLoading = loading),
    );
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Battery All GgEz Telemetry'),
          actions: [
            IconButton(
              icon: const Icon(Icons.refresh),
              //  Rebuilds the page view, runs loader animations, and updates native hardware stats in one single execution line
              onPressed: () => BatteryAllGgez.refresh(
                onNotify: () => setState(() {}),
                onStateChanged: (loading) => setState(() => _isLoading = loading),
              ),
            ),
          ],
        ),
        body: _isLoading
            ? const Center(child: CircularProgressIndicator())
            : ListView(
                padding: const EdgeInsets.all(16.0),
                children: [
                  _buildSectionHeader("Level Metric Matrix"),
                  _buildCard("Calculated Percentage", "${BatteryAllGgez.percentage}%"),
                  _buildCard("Raw Register Level", "${BatteryAllGgez.rawLevel}"),
                  _buildCard("Hardware Raw Scale", "${BatteryAllGgez.rawScale}"),
                  _buildCard("Is Battery Low Alert", BatteryAllGgez.isBatteryLow ? "YES (Low)" : "No"),
                  _buildSectionHeader("Electrical & Thermal Physics"),
                  _buildCard("Tension Voltage Force", "${BatteryAllGgez.voltage} V"),
                  _buildCard("Voltage In Millivolts", "${BatteryAllGgez.voltageMilliVolts} mV"),
                  _buildCard("Pack Core Temperature", "${BatteryAllGgez.temperature}°C"),
                  _buildCard("Current Draw Snap Now", "${BatteryAllGgez.currentNow} mA"),
                  _buildCard("Smoothed Average Current", "${BatteryAllGgez.currentAverage} mA"),
                  _buildSectionHeader("Chemical & Lifespan Architecture"),
                  _buildCard("Factory Design Size", "${BatteryAllGgez.capacity} mAh"),
                  _buildCard("Remaining Microamps", "${BatteryAllGgez.remainingMicroAmpHours} µAh"),
                  _buildCard("Remaining Energy NanoWh", "${BatteryAllGgez.remainingNanoWattHours} nWh"),
                  _buildCard("BMS Structural Health", BatteryAllGgez.health),
                  _buildCard("Cell Chemical Comp", BatteryAllGgez.chemistry),
                  _buildCard("Physical Battery Present", BatteryAllGgez.isPresent ? "Yes" : "No"),
                  _buildCard("Lifetime Hardware Cycles", BatteryAllGgez.cycleCount == -1 ? "Unsupported by Phone OEM" : "${BatteryAllGgez.cycleCount} Cycles"),
                  _buildSectionHeader("Connectivity System Metrics"),
                  _buildCard("BMS Operating Status", BatteryAllGgez.status),
                  _buildCard("Hardware Input Interface", BatteryAllGgez.pluggedSource),
                  _buildCard("Projection Time To Full", BatteryAllGgez.chargeTimeRemainingMs == -1 ? "Not Active / Discharging" : "${(BatteryAllGgez.chargeTimeRemainingMs / 1000 / 60).toStringAsFixed(1)} mins"),
                ],
              ),
      ),
    );
  }

  Widget _buildCard(String title, String value) {
    return Card(
      margin: const EdgeInsets.symmetric(vertical: 4.0),
      child: ListTile(
        title: Text(title, style: const TextStyle(fontWeight: FontWeight.w500)),
        trailing: Text(value, style: const TextStyle(fontWeight: FontWeight.bold)),
      ),
    );
  }
}

Widget _buildSectionHeader(String title) {
  return Padding(
    padding: const EdgeInsets.only(top: 16.0, bottom: 8.0, left: 4.0),
    child: Text(
      title,
      style: const TextStyle(fontSize: 14, fontWeight: FontWeight.bold, color: Colors.blueGrey),
    ),
  );
}
1
likes
160
points
158
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A new Flutter plugin to access all battery information in an ez way.

Homepage

License

MIT (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on battery_all_ggez

Packages that implement battery_all_ggez