mani_plugin 0.0.2 copy "mani_plugin: ^0.0.2" to clipboard
mani_plugin: ^0.0.2 copied to clipboard

A Flutter plugin to monitor battery health including level, charging status, temperature, and health status for Android and iOS.

example/lib/main.dart

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

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

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

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

class _MyAppState extends State<MyApp> {
  final _plugin = ManiPlugin();

  int? _level;
  String? _status;
  double? _temperature;
  String? _health;

  Future<void> _fetchBatteryInfo() async {
    final info = await _plugin.getAllBatteryInfo();
    setState(() {
      _level = info?['level'];
      _status = info?['chargingStatus'];
      _temperature = info?['temperature'];
      _health = info?['health'];
    });
  }

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: const Text('Battery Health Monitor')),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              Text('🔋 Level: $_level%', style: const TextStyle(fontSize: 22)),
              const SizedBox(height: 12),
              Text('⚡ Status: $_status', style: const TextStyle(fontSize: 22)),
              const SizedBox(height: 12),
              Text('🌡 Temperature: ${_temperature ?? "N/A"}°C',
                  style: const TextStyle(fontSize: 22)),
              const SizedBox(height: 12),
              Text('❤️ Health: ${_health ?? "N/A"}',
                  style: const TextStyle(fontSize: 22)),
              const SizedBox(height: 30),
              ElevatedButton(
                onPressed: _fetchBatteryInfo,
                child: const Text('Refresh'),
              )
            ],
          ),
        ),
      ),
    );
  }
}
1
likes
140
points
26
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter plugin to monitor battery health including level, charging status, temperature, and health status for Android and iOS.

Homepage

Documentation

API reference

License

MIT (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on mani_plugin

Packages that implement mani_plugin