flutter_app_settings 0.0.2 copy "flutter_app_settings: ^0.0.2" to clipboard
flutter_app_settings: ^0.0.2 copied to clipboard

It is app setting package which helps to open setting screen programmatically.

example/lib/main.dart

import 'dart:async';

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

/// Main method to return runApp.
void main() => runApp(MyApp());

/// This is the main app stateful widget.
class MyApp extends StatefulWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  MyAppState createState() => MyAppState();
}

/// This is the app state.
class MyAppState extends State<MyApp> {
  @override
  void initState() {
    /// Call out to intialize platform state.
    initPlatformState();
    super.initState();
  }

  /// Initialize platform state.
  Future<void> initPlatformState() async {
    // If the widget was removed from the tree while the asynchronous platform
    // message was in flight, we want to discard the reply rather than calling
    // setState to update our non-existent appearance.
    if (!mounted) return;
  }

  /// Widget build method to return MaterailApp.
  @override
  Widget build(BuildContext context) {
    var actionItems = getListOfActionButtons();
    return MaterialApp(
        home: Scaffold(
            appBar: AppBar(
              title: const Text('App Settings Example App'),
            ),
            body: GridView.count(
                crossAxisCount: 2,
                childAspectRatio: 2,
                children: List.generate(actionItems.length, (index) {
                  return Center(
                      child: ButtonTheme(
                    colorScheme: ColorScheme.dark(),
                    minWidth: 150.0,
                    child: actionItems[index],
                  ));
                }))));
  }

  List<Widget> getListOfActionButtons() {
    var actionItems = <Widget>[];

    actionItems.addAll([
      ElevatedButton(
        child: Text("WIFI"),
        onPressed: () {
          FlutterAppSettings.openWIFISettings();
        },
      ),
      ElevatedButton(
        child: Text("Location"),
        onPressed: () {
          FlutterAppSettings.openLocationSettings();
        },
      ),
      ElevatedButton(
        child: Text("Security"),
        onPressed: () {
          FlutterAppSettings.openSecuritySettings();
        },
      ),
      ElevatedButton(
        child: Text("Lock & Password"),
        onPressed: () {
          FlutterAppSettings.openLockAndPasswordSettings();
        },
      ),
      ElevatedButton(
        child: Text("App Settings"),
        onPressed: () {
          FlutterAppSettings.openAppSettings();
        },
      ),
      ElevatedButton(
        child: Text("Bluetooth"),
        onPressed: () {
          FlutterAppSettings.openBluetoothSettings();
        },
      ),
      ElevatedButton(
        child: Text("Data Roaming"),
        onPressed: () {
          FlutterAppSettings.openDataRoamingSettings();
        },
      ),
      ElevatedButton(
        child: Text("Date"),
        onPressed: () {
          FlutterAppSettings.openDateSettings();
        },
      ),
      ElevatedButton(
        child: Text("Display"),
        onPressed: () {
          FlutterAppSettings.openDisplaySettings();
        },
      ),
      ElevatedButton(
        child: Text("Notification"),
        onPressed: () {
          FlutterAppSettings.openNotificationSettings();
        },
      ),
      ElevatedButton(
        child: Text("Sound"),
        onPressed: () {
          FlutterAppSettings.openSoundSettings();
        },
      ),
      ElevatedButton(
        child: Text("Internal Storage"),
        onPressed: () {
          FlutterAppSettings.openInternalStorageSettings();
        },
      ),
      ElevatedButton(
        child: Text("Battery optimization"),
        onPressed: () {
          FlutterAppSettings.openBatteryOptimizationSettings();
        },
      ),
      ElevatedButton(
        child: Text("NFC"),
        onPressed: () {
          FlutterAppSettings.openNFCSettings();
        },
      ),
      ElevatedButton(
        child: Text("VPN"),
        onPressed: () {
          FlutterAppSettings.openVPNSettings(
            asAnotherTask: true,
          );
        },
      ),
      ElevatedButton(
        child: Text("Device Settings"),
        onPressed: () {
          FlutterAppSettings.openDeviceSettings(
            asAnotherTask: true,
          );
        },
      ),
      ElevatedButton(
        child: Text("Accessibility"),
        onPressed: () {
          FlutterAppSettings.openAccessibilitySettings(
            asAnotherTask: true,
          );
        },
      ),
      ElevatedButton(
        child: Text("Developer"),
        onPressed: () {
          FlutterAppSettings.openDevelopmentSettings(
            asAnotherTask: true,
          );
        },
      ),
      ElevatedButton(
        child: Text("Hotspot"),
        onPressed: () {
          FlutterAppSettings.openHotspotSettings(
            asAnotherTask: true,
          );
        },
      ),
    ]);

    return actionItems;
  }

  /// Dispose method to close out and cleanup objects.
  @override
  void dispose() {
    super.dispose();
  }
}
2
likes
160
points
34
downloads

Publisher

unverified uploader

Weekly Downloads

It is app setting package which helps to open setting screen programmatically.

Homepage

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on flutter_app_settings