system_alert_window 0.1.4+2

  • Readme
  • Changelog
  • Example
  • Installing
  • 84

system_alert_window #

A flutter plugin to show Truecaller like overlay window, over all other apps along with callback events.

Android #

Permissions #

  <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
  <uses-permission android:name="android.permission.FOREGROUND_SERVICE " />
<uses-permission android:name="android.permission.WAKE_LOCK" />

Android 9 and below #

Uses 'draw on top' permission and displays it as a overlay window

Android 10 and above #

Uses Android Bubble APIs to show the overlay window.

IOS #

Displays as a notification in the notification center [Help Needed]

Example #

Show the overlay #

  SystemWindowHeader header = SystemWindowHeader(
          title: SystemWindowText(text: "Incoming Call", fontSize: 10, textColor: Colors.black45),
          padding: SystemWindowPadding.setSymmetricPadding(12, 12),
          subTitle: SystemWindowText(text: "9898989899", fontSize: 14, fontWeight: FontWeight.BOLD, textColor: Colors.black87),
          decoration: SystemWindowDecoration(startColor: Colors.grey[100]),
        );
        
  SystemWindowFooter footer = SystemWindowFooter(
      button: SystemWindowButton(
        text: SystemWindowText(text: "I'm a button", fontSize: 12, textColor: Colors.white),
        tag: "footer_button", //Usefull to identify the callback events
        width: SystemWindowButton.MATCH_PARENT,
        height: SystemWindowButton.WRAP_CONTENT,
        decoration: SystemWindowDecoration(
            startColor: Color.fromRGBO(250, 139, 97, 1), endColor: Color.fromRGBO(247, 28, 88, 1), borderWidth: 0, borderRadius: 30.0),
      ),
      padding: SystemWindowPadding(left: 16, right: 16, bottom: 12),
      decoration: SystemWindowDecoration(startColor: Colors.white),
      buttonPosition: ButtonPosition.CENTER);
      
  SystemWindowBody body = SystemWindowBody(
          rows: [
            EachRow(
              columns: [
                EachColumn(
                  text: SystemWindowText(text: "Some body", fontSize: 12, textColor: Colors.black45),
                ),
              ],
              gravity: ContentGravity.CENTER,
            ),
          ],
          padding: SystemWindowPadding(left: 16, right: 16, bottom: 12, top: 12),
        );

  SystemAlertWindow.showSystemWindow(
      height: 230,
      header: header,
      body: body,
      footer: footer,
      margin: SystemWindowMargin(left: 8, right: 8, top: 100, bottom: 0),
      gravity: SystemWindowGravity.TOP);
      

Register callback events (like button click) #

  SystemAlertWindow.registerCallBack((dynamic arguments) {
        String type = arguments[0];
        if (type == "onClick") {
          String tag = arguments[1];
          print("OnClick event of $tag");
        }
      });
      

Close the overlay #

  SystemAlertWindow.closeSystemWindow();

0.1.4+2 #

  • Fixed an issue where overlay window is crashing during update overlay window call

0.1.4+1 #

  • Fixed an issue where multiple overlay windows are creating during update overlay window call

0.1.4 #

  • Fixed overlay window issue with older Android versions

0.1.3+1 #

  • Fixed a crash with updateSystemWindow method for android 9 and below

0.1.3 #

  • Fixed a bug in closeSystemWindow method
  • Improved permissions checking logic
  • Added support for updating the system alert window

0.1.2 #

  • Moved bubble notification to foreground service, to allow the bubble to display in all cases
  • Fixed the launcher icons of the example

0.1.1+1 #

  • Added logging + Made minor changes to fix crashes with bubbles

0.1.1 - Breaking Changes #

  • Renamed the models to avoid conflicts with the native libraries

0.1.0 #

  • Added support to close the system alert window
  • Improved the permissions API to include support for Android 10

0.0.1 #

  • Initial release (Working only for Android)

example/README.md

system_alert_window_example #

A flutter plugin to show Truecaller like overlay window, over all other apps along with callback events.

Android #

Permissions #

<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE " />
<uses-permission android:name="android.permission.WAKE_LOCK" />

Android 9 and below #

Uses 'draw on top' permission and displays it as a overlay window

Android 10 and above #

Uses Android Bubble APIs to show the overlay window.

IOS #

Displays as a notification in the notification center [Help Needed]

Use this package as a library

1. Depend on it

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


dependencies:
  system_alert_window: ^0.1.4+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:system_alert_window/system_alert_window.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
70
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
84
Learn more about scoring.

We analyzed this package on Jan 19, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.0
  • pana: 0.13.4
  • Flutter: 1.12.13+hotfix.5

Health issues and suggestions

Document public APIs. (-1 points)

180 out of 180 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Format lib/system_alert_window.dart.

Run flutter format to format lib/system_alert_window.dart.

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.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test