mybatteryplugin 0.0.1 copy "mybatteryplugin: ^0.0.1" to clipboard
mybatteryplugin: ^0.0.1 copied to clipboard

flutter plugin test

example/lib/main.dart

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

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

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

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

class _MyAppState extends State<MyApp> {
  // plugin instanciation
  final _mybatterypluginPlugin = Mybatteryplugin();

  // this is where we will store the battery level
  num? _batteryLevel;

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

    // execute the method to retrieve the battery level
    _mybatterypluginPlugin.getBatteryLevel().then((batteryLevel) {
      setState(() {
        _batteryLevel = batteryLevel;
      });
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: Center(
          // we display the battery level
          child: _batteryLevel != null
              ? Text('Niveau de la batterie: $_batteryLevel')
              : const CircularProgressIndicator(),
        ),
      ),
    );
  }
}
1
likes
140
points
1
downloads

Publisher

unverified uploader

Weekly Downloads

flutter plugin test

Documentation

API reference

License

unknown (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on mybatteryplugin

Packages that implement mybatteryplugin