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

PlatformAndroidiOS
outdated

A new Flutter project.

example/lib/main.dart

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
120
pub points
27%
popularity

Publisher

unverified uploader

A new Flutter project.

Repository (GitHub)

Documentation

API reference

License

unknown (license)

Dependencies

flutter

More

Packages that depend on batterycapacity