A Flutter Plugin for Opening Phone Settings From android and IOS Apps

flutter_open_app_settings

A Flutter Plugin for opening phone settings from Android and iOS apps. It is a fully customizable plugin that allows you to execute functions when returning from the app settings pages.

Installation

Add following dependency in pubspec.yaml file:

flutter_open_app_settings:^0.1.0

Install by running:

flutter pub get

Usage

Usage implementation using a ElevatedButton 'onPressed' event.

import 'package:flutter_open_app_settings/flutter_open_app_settings.dart';

  Widget build(BuildContext context) {
    return Row(
      children: <Widget>[
        ElevatedButton(onPressed: () {
          FlutterOpenAppSettings.openAppsSettings(settingsCode: SettingsCode.APP_SETTINGS,
            onCompletion: _function);},
            child: Text("OPEN APP SETTINGS")),
      ],
    );
  }

openAppsSettings function takes 2 arguments. The first one is required and accepts the Setting code. The second is optional and accepts a function. The function will be executed after returning from the settings page.

 Function _function = (){
      print("do stuff here After returning back to setting page!");
    };

iOS only supports single settings pages instead of custom setting pages.

SettingsCode

 enum SettingsCode{
    APP_SETTINGS,
    BLUETOOTH,
    WIFI,
    ACCESSIBILITY,
    ADD_ACCOUNT,
    AIRPLANE_MODE,
    APN,
    ALL_APPS_SETTINGS,
    BATTERY_SAVER,
    KEYBOARD,
    DATA_USAGE,
    DATE,
    DEVICE_INFO,
    DISPLAY,
    HOME,
    INTERNAL_STORAGE,
    FINGERPRINT_ENROLL,
    LOCALE,
    LOCATION,
    PRIVACY,
    BATTERY_OPTIMIZATION,
    NFC,
    SOUND,
    NOTIFICATION,
}

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Follow me

https://github.com/josephcrowell

Use this package as a library

Depend on it

Run this command:

With Flutter:

 $ flutter pub add flutter_open_app_settings

This will add a line like this to your package's pubspec.yaml (and run an implicit flutter pub get):

dependencies:
  flutter_open_app_settings: ^0.1.0

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

Import it

Now in your Dart code, you can use:

import 'package:flutter_open_app_settings/flutter_open_app_settings.dart'; 

example/lib/main.dart

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_open_app_settings/flutter_open_app_settings.dart';

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

class ExampleApp extends StatefulWidget {
  const ExampleApp({Key? key}) : super(key: key);

  @override
  State<ExampleApp> createState() => _ExampleAppState();
}

class _ExampleAppState extends State<ExampleApp> {
  late Function _function;

  @override
  void initState() {
    super.initState();
    _function = () {
      if (kDebugMode) {
        print('do stuff here After returning back to setting page!');
      }
    };
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData(
        primaryColor: Colors.deepPurple,
      ),
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Open Apps Setting Plugin Example'),
        ),
        body: Center(
          child: SingleChildScrollView(
            child: Column(
              children: <Widget>[
                const SizedBox(
                  height: 10,
                ),
                ElevatedButton(
                  onPressed: () {
                    FlutterOpenAppSettings.openAppsSettings(
                      settingsCode: SettingsCode.APP_SETTINGS,
                      onCompletion: _function,
                    );
                  },
                  child: const Text('OPEN APP SETTINGS'),
                ),
                const SizedBox(
                  height: 10,
                ),
                ElevatedButton(
                  onPressed: () {
                    FlutterOpenAppSettings.openAppsSettings(
                      settingsCode: SettingsCode.BLUETOOTH,
                    );
                  },
                  child: const Text('OPEN BLUETOOTH SETTINGS'),
                ),
                const SizedBox(
                  height: 10,
                ),
                ElevatedButton(
                  onPressed: () {
                    FlutterOpenAppSettings.openAppsSettings(
                      settingsCode: SettingsCode.WIFI,
                    );
                  },
                  child: const Text('OPEN WIFI SETTINGS'),
                ),
                const SizedBox(
                  height: 10,
                ),
                ElevatedButton(
                  onPressed: () {
                    FlutterOpenAppSettings.openAppsSettings(
                      settingsCode: SettingsCode.ACCESSIBILITY,
                    );
                  },
                  child: const Text('OPEN ACCESSIBILITY SETTINGS'),
                ),
                const SizedBox(
                  height: 10,
                ),
                ElevatedButton(
                  onPressed: () {
                    FlutterOpenAppSettings.openAppsSettings(
                      settingsCode: SettingsCode.ADD_ACCOUNT,
                    );
                  },
                  child: const Text('OPEN ADD ACCOUNT SETTINGS'),
                ),
                const SizedBox(
                  height: 10,
                ),
                ElevatedButton(
                  onPressed: () {
                    FlutterOpenAppSettings.openAppsSettings(
                      settingsCode: SettingsCode.AIRPLANE_MODE,
                    );
                  },
                  child: const Text('OPEN AIRPLANE SETTINGS'),
                ),
                const SizedBox(
                  height: 10,
                ),
                ElevatedButton(
                  onPressed: () {
                    FlutterOpenAppSettings.openAppsSettings(
                      settingsCode: SettingsCode.ALL_APPS_SETTINGS,
                    );
                  },
                  child: const Text('OPEN ALL APP SETTINGS'),
                ),
                const SizedBox(
                  height: 10,
                ),
                ElevatedButton(
                  onPressed: () {
                    FlutterOpenAppSettings.openAppsSettings(
                      settingsCode: SettingsCode.APN,
                    );
                  },
                  child: const Text('OPEN APN SETTINGS'),
                ),
                const SizedBox(
                  height: 10,
                ),
                ElevatedButton(
                  onPressed: () {
                    FlutterOpenAppSettings.openAppsSettings(
                      settingsCode: SettingsCode.BATTERY_SAVER,
                    );
                  },
                  child: const Text('OPEN BATTERY SAVER SETTINGS'),
                ),
                const SizedBox(
                  height: 10,
                ),
                ElevatedButton(
                  onPressed: () {
                    FlutterOpenAppSettings.openAppsSettings(
                      settingsCode: SettingsCode.KEYBOARD,
                    );
                  },
                  child: const Text('OPEN KEYBOARD SETTINGS'),
                ),
                const SizedBox(
                  height: 10,
                ),
                ElevatedButton(
                  onPressed: () {
                    FlutterOpenAppSettings.openAppsSettings(
                      settingsCode: SettingsCode.DATA_USAGE,
                    );
                  },
                  child: const Text('OPEN DATA USAGE SETTINGS'),
                ),
                const SizedBox(
                  height: 10,
                ),
                ElevatedButton(
                  onPressed: () {
                    FlutterOpenAppSettings.openAppsSettings(
                      settingsCode: SettingsCode.DATE,
                    );
                  },
                  child: const Text('OPEN DATE SETTINGS'),
                ),
                const SizedBox(
                  height: 10,
                ),
                ElevatedButton(
                  onPressed: () {
                    FlutterOpenAppSettings.openAppsSettings(
                      settingsCode: SettingsCode.DEVICE_INFO,
                    );
                  },
                  child: const Text('OPEN DEVICE INFO SETTINGS'),
                ),
                const SizedBox(
                  height: 10,
                ),
                ElevatedButton(
                  onPressed: () {
                    FlutterOpenAppSettings.openAppsSettings(
                      settingsCode: SettingsCode.DISPLAY,
                    );
                  },
                  child: const Text('OPEN DISPLAY SETTINGS'),
                ),
                const SizedBox(
                  height: 10,
                ),
                ElevatedButton(
                  onPressed: () {
                    FlutterOpenAppSettings.openAppsSettings(
                      settingsCode: SettingsCode.HOME,
                    );
                  },
                  child: const Text('OPEN HOME SETTINGS'),
                ),
                const SizedBox(
                  height: 10,
                ),
                ElevatedButton(
                  onPressed: () {
                    FlutterOpenAppSettings.openAppsSettings(
                      settingsCode: SettingsCode.INTERNAL_STORAGE,
                    );
                  },
                  child: const Text('OPEN INTERNAL STORAGE SETTINGS'),
                ),
                const SizedBox(
                  height: 10,
                ),
                ElevatedButton(
                  onPressed: () {
                    FlutterOpenAppSettings.openAppsSettings(
                      settingsCode: SettingsCode.NFC,
                    );
                  },
                  child: const Text('OPEN NFC SETTINGS'),
                ),
                const SizedBox(
                  height: 10,
                ),
                ElevatedButton(
                  onPressed: () {
                    FlutterOpenAppSettings.openAppsSettings(
                      settingsCode: SettingsCode.NOTIFICATION,
                    );
                  },
                  child: const Text('OPEN NOTIFICATION SETTINGS'),
                ),
                const SizedBox(
                  height: 10,
                ),
                ElevatedButton(
                  onPressed: () {
                    FlutterOpenAppSettings.openAppsSettings(
                      settingsCode: SettingsCode.SOUND,
                    );
                  },
                  child: const Text('OPEN SOUND SETTINGS'),
                ),
                const SizedBox(
                  height: 10,
                ),
                ElevatedButton(
                  onPressed: () {
                    FlutterOpenAppSettings.openAppsSettings(
                      settingsCode: SettingsCode.BATTERY_OPTIMIZATION,
                    );
                  },
                  child: const Text('OPEN BATTERY OPTIMIZATION SETTINGS'),
                ),
                const SizedBox(
                  height: 10,
                ),
                ElevatedButton(
                  onPressed: () {
                    FlutterOpenAppSettings.openAppsSettings(
                      settingsCode: SettingsCode.LOCATION,
                    );
                  },
                  child: const Text('OPEN LOCATION SETTINGS'),
                ),
                const SizedBox(
                  height: 10,
                ),
                ElevatedButton(
                  onPressed: () {
                    FlutterOpenAppSettings.openAppsSettings(
                      settingsCode: SettingsCode.LOCALE,
                    );
                  },
                  child: const Text('OPEN LOCALE SETTINGS'),
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }
} 

Download details:

Author: josephcrowell

Source: https://github.com/josephcrowell/flutter_open_app_settings

#flutter #android #ios 

A Flutter Plugin for Opening Phone Settings From android and IOS Apps
1.00 GEEK