settings_panel_android 0.1.2

  • Readme
  • Changelog
  • Example
  • Installing
  • 65

dartsidedev/settings_panel_android #

This Flutter plugin helps you show settings panels directly from your Dart code.

This plugin only works on Android devices with API level 29 or more, as Settings.Panel is an Android 10 feature. On iOS devices and Android devices with older API levels, the plugin simply does not do anything.

GIF Flutter plugin settings_panel_android - Example app in action

Introduction #

Settings.Panel #

Using this Flutter plugin, displaying settings panels is now a breeze also from your Dart code.

Android 10 introduced Settings Panels

Settings Panels is an API that allows apps to show settings to users in the context of their app. This prevents users from needing to go into "Settings" to change things like "NFC" or "Mobile data" in order to use the app.

With Android 10, your app can display an inline panel showing settings (connectivity, WiFi, NFC, and volume) and the user can change these settings without leaving your app. (Android 10 Features)

A Settings panel is floating UI that contains a fixed subset of settings to address a particular user problem. For example, the Internet Panel surfaces settings related to connecting to the internet.

Settings panels appear above the calling app to address the problem without the user needing to open Settings and thus leave their current screen. (Android documentation Settings.Panel)

Usage #

FlatButton(
  child: Text('Open NFC inline settings panel'),
  onPressed: () {
    final action = SettingsPanelAction.nfc
    final successful = await SettingsPanel.display(action);
    if (!successful) {
      // Maybe iOS or old Android version...
      print('Panel was not shown to the user');
    }
  }
)

Example app #

dartsidedev/settings_panel_android example app screenshot displaying internet connectivity settings panel

You can see a very simple example app with its source code and screen recordings in the example folder of this plugin.

FAQ #

What happens on iOS devices? #

The way the plugin is implemented, the iOS platform specific call just returns false. It will not crash your app, but I recommend you check the platform the app is being executed on and call this plugin's method only if you are on Android

import 'dart:io' show Platform;

import 'package:settings_panel_android/settings_panel_android.dart';

// ... example
if (Platform.isAndroid) {
  // Let's show for example a volume settings panel
  SettingsPanel.display(SettingsPanelAction.volume);
}
What happens on Android devices that have API level <29?

The plugin automatically checks the API level on the Android side, so it's safe to use on all versions of Android. On older versions, the Android code simply skips launching the settings panel.

Alternatively, you can also check the Android version from your Dart code, for example, using device_info.

Isn't this just an Intent call?

Yes, you can open settings panels quite simply if you are an experienced Android developer. You can also just launch the intent from your Dart code using android_intent, if you don't want to depend on this package.

In my opinion, the only thing we should assume about Flutter developers is that they know Dart and they want to create beautiful app and great user experiences.

Having a simple Dart API is crucial for great development experience and it can make launching settings panels easier. It provides the right level of abstraction for Dart developers. As a Flutter developer, I don't care about intents, extra flags, and context. All I care about is letting my users switch settings easily by displaying them settings panels. The plugin is well-documented, type safe, tested on different devices and used by many developers (or if it's not used by many yet, then it will be one day).

While writing the plugin, I committed so many small mistakes, that a simple feature like this took me hours to implement 90% correctly. Publishing a plugin lets other developers completely skip this learning and debugging phase and they can focus on creating great experiences on modern Android devices.

What about the other 10%? Well, I don't know about any issues yet, but if you find something, create an issue.

Do you have an issue with the plugin? Check if there is already an issue filed for your problem.

About #

Created and maintained by Vince Varga.

0.1.2 #

Add license.

0.1.1 #

Small improvements.

  • Add iOS dummy implementation
  • Make screenshots and gif smaller in markdown files
  • dartfmt... fml.

0.1.0 #

Initial release.

example/README.md

settings_panel_android_example #

Demonstrates how to use the settings_panel_android plugin.

Screenshots and screen recordings #

GIF Flutter plugin settings_panel_android - Example app in action

The panels might look different on different devices.

Internet connectivity panel #

SettingsPanel.display(SettingsPanelAction.internetConnectivity);
Flutter plugin settings_panel_android - Example app Internet connectivity panel

NFC panel #

SettingsPanel.display(SettingsPanelAction.nfc);
Flutter plugin settings_panel_android - Example app NFC panel

Volume panel #

SettingsPanel.display(SettingsPanelAction.volume);
Flutter plugin settings_panel_android - Example app Volume panel

WiFi panel #

SettingsPanel.display(SettingsPanelAction.wifi);
Flutter plugin settings_panel_android - Example app Wi-Fi panel

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  settings_panel_android: ^0.1.2

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

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

3. Import it

Now in your Dart code, you can use:


import 'package:settings_panel_android/settings_panel_android.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
31
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
65
Learn more about scoring.

We analyzed this package on Dec 7, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.6.1
  • pana: 0.12.21
  • Flutter: 1.9.1+hotfix.6

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health suggestions

Fix lib/settings_panel_android.dart. (-0.50 points)

Analysis of lib/settings_panel_android.dart reported 1 hint:

line 65 col 1: This function has a return type of 'String', but doesn't end with a return statement.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.7 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test