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

PlatformAndroid

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),
              )
            ],
          ),
        ),
      ),
    );
  }
}
1
likes
150
pub points
48%
popularity
screenshot

Publisher

verified publisherc-wolf.dev

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

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on autostart_settings