app_settings Flutter Plugin

repository·master·Indexed 19 days ago

https://github.com/spencerccf/app_settings

A Flutter plugin that allows developers to programmatically open system settings pages, such as Wi-Fi, Location, or Volume, on iOS and Android. It provides the openAppSettings() method for general settings and openAppSettingsPanel() for Android Q (API 29) and higher settings panels.

Tokens
1.1K
Snippets
7
Records
7
Agent score
65%

What's inside app_settings

  1. Configure iOS for app_settings

    master

    Depending on your iOS integration method, you may need to perform additional configuration:

    Objective-C Projects

    If your iOS project uses Objective-C, you must add use_frameworks! to your Runner project podfile to support this Swift-based plugin:

    target 'Runner' do
      use_frameworks!
    end

    Swift Package Manager (SPM)

    If you prefer using Swift Package Manager, ensure Swift support is enabled in your Flutter configuration:

    flutter config --enable-swift-package-manager
  2. Customize iOS Launch Screen Assets

    master

    To change the images used for the iOS launch screen, you can either replace the image files directly in the example/ios/Runner/Assets.xcassets/LaunchImage.imageset/ directory or use Xcode for a more visual approach.

    Using Xcode:

    1. Open your Flutter project's iOS workspace using open ios/Runner.xcworkspace.
    2. In the Xcode Project Navigator, navigate to Runner/Assets.xcassets.
    3. Drag and drop your desired images into the asset catalog.
    open ios/Runner.xcworkspace
  3. Open system settings with openAppSettings()

    master

    Use AppSettings.openAppSettings() to navigate the user to specific system settings pages.

    • Default Behavior: If no type is provided, it defaults to AppSettingsType.settings, which opens the general application settings.
    • Fallback: If the requested AppSettingsType is not supported on the current platform, the plugin will open the general settings instead.
    • Android Specific: You can set asAnotherTask: true to open the settings page in a different Activity.
    Widget build(BuildContext context) {
      return ElevatedButton(
        onPressed: () => AppSettings.openAppSettings(type: AppSettingsType.location),
        child: const Text('Open Location Settings'),
      );
    }
  4. Open Android Q+ Settings Panels

    master

    On Android Q (API level 29) and higher, you can open specific Settings Panels using AppSettings.openAppSettingsPanel().

    Note: Settings panels are only supported on Android; calling this on other platforms will not function as intended for panels.

    Widget build(BuildContext context) {
      return ElevatedButton(
        onPressed: () => AppSettings.openAppSettingsPanel(AppSettingsPanelType.volume),
        child: const Text('Open Volume Settings Panel'),
      );
    }
  5. Open specific Android settings panels with openAppSettingsPanel()

    master

    Use AppSettings.openAppSettingsPanel(type) to open a specific application settings panel.

    Platform Support:

    • Android: Supported only on Android Q (API 29) and higher. On Android Pie and lower, this method does nothing.
    • Other Platforms: This method is specific to Android settings panels.
    import 'package:app_settings/app_settings.dart;
    
    // Open a specific settings panel (e.g., Notifications)
    await AppSettings.openAppSettingsPanel(AppSettingsPanelType.notifications);
  6. Open app settings with openAppSettings()

    master

    Use AppSettings.openAppSettings() to navigate the user to the application's settings screen.

    • type: Specifies a particular settings panel if supported by the platform. Defaults to AppSettingsType.settings.
    • asAnotherTask: A boolean available on Android. If set to true, the settings screen opens as a separate task in the recent apps list.
    import 'package:app_settings/app_settings.dart';
    
    // Open general app settings
    await AppSettings.openAppSettings();
    
    // Open specific settings as a separate task on Android
    await AppSettings.openAppSettings({
      'type': AppSettingsType.settings,
      'asAnotherTask': true,
    });