batterycapacity 0.0.4 copy "batterycapacity: ^0.0.4" to clipboard
batterycapacity: ^0.0.4 copied to clipboard

Flutter plugin, inspired by battery package, providing detailed information about the device total battery capacity.

Battery Total Capacity Information #

Flutter plugin providing detailed information about the device total battery capacity (mAh). Now support android.

Example #

// Import package
import 'package:flutter/material.dart';
import 'dart:async';

import 'package:flutter/services.dart';
import 'package:my_plugin/my_plugin.dart';

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

class MyApp extends StatefulWidget {
  const MyApp({Key? key}) : super(key: key);

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

class _MyAppState extends State<MyApp> {
  double _totalBatteryCapacity = -1;

  @override
  void initState() {
    super.initState();
    initBatteryCapacityState();
  }

  Future<void> initBatteryCapacityState() async {
    double? totalBatteryCapacity;

    await MyPlugin.batteryCapacity.then((value) {
      totalBatteryCapacity = value;
    });

    if (!mounted) return;

    setState(() {
      _totalBatteryCapacity = totalBatteryCapacity!;
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Battery Capacity Plugin'),
        ),
        body: Center(
          child:
              Text('Get the total battery capacity: $_totalBatteryCapacity\n'),
        ),
      ),
    );
  }
}
5
likes
130
pub points
31%
popularity

Publisher

unverified uploader

Flutter plugin, inspired by battery package, providing detailed information about the device total battery capacity.

Repository (GitHub)

Documentation

API reference

License

unknown (license)

Dependencies

flutter

More

Packages that depend on batterycapacity