autostart_settings 0.1.2 copy "autostart_settings: ^0.1.2" to clipboard
autostart_settings: ^0.1.2 copied to clipboard

Plugin to check if autostart settings is available for the device and opens the autostart settings

example/lib/main.dart

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

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

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

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

class _MyAppState extends State<MyApp> {
  String _text = '';

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Autostart example app'),
        ),
        body: Center(
          child: Column(
            mainAxisSize: MainAxisSize.min,
            children: [
              Padding(
                padding: const EdgeInsets.all(8.0),
                child: ElevatedButton(
                    onPressed: () async {
                      final canOpen = await AutostartSettings.canOpen(
                          autoStart: true, batterySafer: true);
                      setState(() {
                        if (canOpen) {
                          _text = 'device can open autostart Settings';
                        } else {
                          _text = 'device doesn\'t have autostart settings activity';
                        }
                      });
                    },
                    child: const Text('Can open autostart settings')),
              ),
              Padding(
                padding: const EdgeInsets.all(8.0),
                child: ElevatedButton(
                    onPressed: () async {
                      final opened = await AutostartSettings.open(
                          autoStart: true, batterySafer: true);
                      setState(() {
                        _text = 'Settings opened: $opened';
                      });
                    },
                    child: const Text('Open autostart Settings')),
              ),
              Padding(
                padding: const EdgeInsets.all(8.0),
                child: Text(_text),
              )
            ],
          ),
        ),
      ),
    );
  }
}
3
likes
0
points
278
downloads

Publisher

verified publisherc-wolf.dev

Weekly Downloads

Plugin to check if autostart settings is available for the device and opens the autostart settings

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on autostart_settings