battery_optimization_helper 0.0.5 copy "battery_optimization_helper: ^0.0.5" to clipboard
battery_optimization_helper: ^0.0.5 copied to clipboard

A Flutter plugin to disable or request disabling battery optimization on Android.

example/lib/main.dart

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

void main() => runApp(const MyApp());

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: const Text('Battery Optimization Helper')),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              ElevatedButton(
                onPressed: () async {
                  final isEnabled =
                      await BatteryOptimizationHelper.isBatteryOptimizationEnabled();
                  debugPrint("Battery optimization enabled: $isEnabled");
                },
                child: const Text("Check Optimization"),
              ),
              ElevatedButton(
                onPressed: () async {
                  await BatteryOptimizationHelper.requestDisableBatteryOptimization();
                },
                child: const Text("Request Disable"),
              ),
              ElevatedButton(
                onPressed: () async {
                  await BatteryOptimizationHelper.openBatteryOptimizationSettings();
                },
                child: const Text("Open Settings"),
              ),
              const Divider(),
              ElevatedButton(
                onPressed: () async {
                  await BatteryOptimizationHelper.openAutoStartSettings();
                },
                child: const Text("Background autostart"),
              ),
            ],
          ),
        ),
      ),
      debugShowCheckedModeBanner: false,
    );
  }
}
0
likes
0
points
451
downloads

Publisher

verified publishertechlinkmyanmar.com

Weekly Downloads

A Flutter plugin to disable or request disabling battery optimization on Android.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on battery_optimization_helper

Packages that implement battery_optimization_helper