auto_start_permission 1.0.1 copy "auto_start_permission: ^1.0.1" to clipboard
auto_start_permission: ^1.0.1 copied to clipboard

PlatformAndroid

Flutter plugin for setting up auto start permission - ANDROID ONLY

example/lib/main.dart

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

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

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

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

class _MyAppState extends State<MyApp> {
  bool _isMiui = false;
  bool _isAutoStartPermissionAvailable = false;
  var _autoStartPermissionState = AutoStartPermissionState.noInfo;

  @override
  void initState() {
    super.initState();
    AutoStartPermission.instance.isOnMiui().then((val) {
      setState(() {
        _isMiui = val;
      });
    });
    AutoStartPermission.instance.isAutoStartPermissionAvailable().then((val) {
      setState(() {
        _isAutoStartPermissionAvailable = val;
      });
    });
    _checkPermissionStatus();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Auto Start Permission Example'),
        ),
        body: Center(
          child: Column(
            children: [
              Text('Is Miui: $_isMiui'),
              Text(
                  'Is AutoStart Permission Available: $_isAutoStartPermissionAvailable'),
              Text(
                  'AutoStartPermissionState: ${_autoStartPermissionState.name}'),
              ElevatedButton(
                onPressed: () async {
                  await AutoStartPermission.instance
                      .requestAutoStartPermission();
                  _checkPermissionStatus();
                },
                child: const Text('request AutoStart Permission'),
              ),
            ],
          ),
        ),
      ),
    );
  }

  void _checkPermissionStatus() {
    AutoStartPermission.instance.checkAutoStartState().then(
      (value) {
        setState(() {
          _autoStartPermissionState = value;
        });
      },
    );
  }
}
4
likes
160
points
30
downloads

Publisher

verified publisherrosskh.tech

Weekly Downloads

Flutter plugin for setting up auto start permission - ANDROID ONLY

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on auto_start_permission