パッケージ、リポジトリ、アプリカテゴリを検索

system_alert_window のカバー
パッケージ詳細v2.0.11

system_alert_window

すべての他のアプリの上にTruecallerのようなオーバーレイウィンドウを表示するFlutterプラグインと、コールバックイベントを含むものです。

AndroidiOS
30日間ダウンロード
7950
いいね数
253
Pub ポイント
150

パッケージをインストール

flutter pub add system_alert_window

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

AndroidおよびiOSで永続的かつシステムレベルのオーバーレイウィンドウを表示できるFlutterプラグインです。Truecallerのアラートインターフェースに似ています。すべての他のアプリケーションの上に表示され、ユーザーの操作に対するコールバックイベントをサポートしています。高可視性の通知や緊急アラート用に設計されており、ネイティブシステム権限とシームレスに統合されます。標準的なプッシュ通知に頼らず、ユーザーの即時注意を引く必要があるアプリケーションに有用です。

用途

  • 緊急アラートを表示しています
  • 常に最前面に表示される通知ウィンドウの作成
  • 通話ブロッキングインターフェースの実装
  • リアルタイムステータスオーバーレイの有効化
  • システムレベルのインタラクションプロンプトを提供する

主な機能

  • システムオーバーレイサポート
  • クロスプラットフォーム(Android および iOS)
  • コールバックイベント処理
  • 他のアプリ上の永続表示
  • システム権限設定との統合

適している対象

  • セキュリティとプライバシー アプリ
  • 通話管理ツール
  • リアルタイムモニタリングユーティリティ
  • 緊急警報システム
  • 高優先度のユーザー操作が必要なアプリ

注意事項

  • Androidでシステム権限が必要です
  • プラットフォーム制限により、iOSの機能が制限されています
  • セキュリティアプリによってマークされる可能性があります
  • ユーザーは手動でオーバーレイ権限を有効にする必要があります
  • バッテリーおよびパフォーマンスへの潜在的な影響

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

system_alert_window

Pub

A flutter plugin to show Truecaller like overlay window, over all other apps along with callback events. Android Go or Android 11 & above, this plugin shows notification bubble, in other android versions, it shows an overlay window.

Android

Demo
1. Clip of example app and 2. Working of button click in the background

      

Manifest
  //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" />


      <application
          //Linking the previously added application class
          android:name=".Application"
          android:label="system_alert_window_example"
          android:icon="@mipmap/ic_launcher">
Android 10 & below, Android GO (API 27)

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

Android 11 & above

With SystemWindowPrefMode.OVERLAY, system alert windows uses 'overlay functionality' wherever it's supported. In that mode, it will show as bubbles if the 'display over other apps' is not supported. With SystemWindowPrefMode.DEFAULT/SystemWindowPrefMode.BUBBLE, User has to allow 'All conversations can bubble' in the notification settings of the app. Uses Android Bubble APIs to show the overlay window inside a notification bubble.

Edge-to-edge content and window insets are handled automatically inside the bubble container — wrap your overlay widget with SafeArea to avoid content being obscured by system bars.

Android GO (API 29)

User has to manually enable bubbles from the developer options. Uses Android Bubble APIs to show the overlay window inside a notification bubble.

IOS

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

Example

Show Overlay
Request overlay permission
  await SystemAlertWindow.requestPermissions;
Inside main.dart create an entry point for your Overlay widget;
// overlay entry point
@pragma("vm:entry-point")
void overlayMain() {
  runApp(const MaterialApp(
    debugShowCheckedModeBanner: false,
    home: Material(child: Text("My overlay"))
  ));
}


 //Open overLay content

//  - Optional arguments:
/// `gravity` Position of the window and default is [SystemWindowGravity.CENTER]
/// `width` Width of the window and default is [Constants.MATCH_PARENT]
/// `height` Height of the window and default is [Constants.WRAP_CONTENT]
/// `notificationTitle` Notification title, applicable in case of bubble
/// `notificationBody` Notification body, applicable in case of bubble
/// `prefMode` Preference for the system window. Default is [SystemWindowPrefMode.DEFAULT]
/// `layoutParamFlags` List of List of WindowManager.LayoutParams. This is not applicable for bubbles.
await SystemAlertWindow.showSystemWindow();

/// update the overlay flag while the overlay in action
///   - Optional arguments:
/// `gravity` Position of the window and default is [SystemWindowGravity.CENTER]
/// `width` Width of the window and default is [Constants.MATCH_PARENT]
/// `height` Height of the window and default is [Constants.WRAP_CONTENT]
/// `notificationTitle` Notification title, applicable in case of bubble
/// `notificationBody` Notification body, applicable in case of bubble
/// `prefMode` Preference for the system window. Default is [SystemWindowPrefMode.DEFAULT]
/// `layoutParamFlags` List of List of WindowManager.LayoutParams. This is not applicable for bubbles.
await FlutterOverlayWindow.updateSystemWindow();

 // closes overlay if open
await SystemAlertWindow.closeSystemWindow();

 // broadcast data to overlay app from main app
await SystemAlertWindow.sendMessageToOverlay("Hello from the other side");

 //streams message from main app to overlay.
SystemAlertWindow.overlayListener.listen((event) {
log("Current Event: $event");
});




Isolate communication
Use this snippet, if you want the callbacks on your main thread
Create an isolate_manager.dart
import 'dart:isolate';

import 'dart:ui';

class IsolateManager{

  static const FOREGROUND_PORT_NAME = "foreground_port";

  static SendPort lookupPortByName() {
    return IsolateNameServer.lookupPortByName(FOREGROUND_PORT_NAME);
  }

  static bool registerPortWithName(SendPort port) {
    assert(port != null, "'port' cannot be null.");
    removePortNameMapping(FOREGROUND_PORT_NAME);
    return IsolateNameServer.registerPortWithName(port, FOREGROUND_PORT_NAME);
  }

  static bool removePortNameMapping(String name) {
    assert(name != null, "'name' cannot be null.");
    return IsolateNameServer.removePortNameMapping(name);
  }

}
While initializing system alert window in your code
    await SystemAlertWindow.checkPermissions;
    ReceivePort _port = ReceivePort();
    IsolateManager.registerPortWithName(_port.sendPort);
    _port.listen((message) {
          log("message from OVERLAY: $message");
          print("Do what ever you want here. This is inside your application scope");
    });
Use this to send data to isolate mentioned above
void callBackFunction(String tag) {
  print("Got tag " + tag);
  SendPort port = IsolateManager.lookupPortByName();
  port.send(tag);
}

カテゴリー

ソースリポジトリ

このパッケージを使用しているプロジェクト

データはまだありません。