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

Flutter Ignore Battery Optimization Permission for Andorid Devices :)

example/lib/main.dart

// ignore_for_file: unused_local_variable

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

import 'package:flutter/services.dart';
import 'package:flutter_ignorebatteryoptimization/flutter_ignorebatteryoptimization.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> {
  final _flutterIgnorebatteryoptimizationPlugin =
      FlutterIgnorebatteryoptimization();

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

  Future<void> openIgnorebatteryoptimizationPlugin() async {
    String ignoreBatteryOptimization;
    try {
      ignoreBatteryOptimization = await _flutterIgnorebatteryoptimizationPlugin
              .showIgnoreBatteryOptimizationSettings() ??
          'Unknown ignoreBatteryOptimization';
    } on PlatformException {
      ignoreBatteryOptimization = 'Failed to show ignoreBatteryOptimization.';
    }
    if (!mounted) return;
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Flutter IgnoreBatteryOptimization'),
        ),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              ElevatedButton(
                onPressed: () {
                  openIgnorebatteryoptimizationPlugin();
                },
                child: const Text(
                    "Request ignore-battery-optimization permission"),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
2
likes
140
points
30
downloads

Publisher

unverified uploader

Weekly Downloads

Flutter Ignore Battery Optimization Permission for Andorid Devices :)

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on flutter_ignorebatteryoptimization