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

flutter_overlay_window のカバー
パッケージ詳細v1.0.2

flutter_overlay_window

画面の他のアプリケーションの上にFlutterアプリを表示するためのFlutterプラグイン

Android
30日間ダウンロード
1.6万
いいね数
532
Pub ポイント
160

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

flutter pub add flutter_overlay_window

パッケージ概要

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

Flutterプラグインで、Android上の他のアプリケーションの上にコンテンツを表示できるようにします。たとえば、フローティングウィンドウやオーバーレイです。開発者は、異なるアプリケーションコンテキスト間で常に表示される永続的なUI要素を作成でき、チャットヘッド、メディアコントロール、リアルタイム通知などのツールに最適です。このプラグインはAndroidシステムのオーバーレイ権限と統合されており、オーバーレイウィンドウの位置、表示状態、インタラクションを管理するためのシンプルなAPIを提供しています。フルスクリーンの中断なしにユーザーの継続的な注目を必要とするアプリに特に役立ちます。

用途

  • フローティングチャットヘッド
  • リアルタイム通知
  • メディアコントロールオーバーレイ
  • 永続的なUIウィジェット
  • スクリーンレコーディングヘルパー

主な機能

  • Android専用のサポート
  • システムオーバーレイ権限の処理
  • カスタマイズ可能なオーバーレイのサイズと位置
  • 表示/非表示用の簡単なAPI
  • バックグラウンド実行の互換性

適している対象

  • 永続的な画面要素を必要とするアプリ
  • インタラクティブなオーバーレイを開発する開発者
  • 最小限のユーザー操作を必要とするツール
  • Android向けのFlutterプロジェクト
  • アクセシビリティまたはユーティリティアプリ

注意事項

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

元の README

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

auto_route_logo

MIT License stars pub version

Buy Me A Coffee

Flutter plugin for displaying your Flutter app over other apps on the screen


Preview

TrueCaller overlay example click-through overlay example Messanger chat-head example

Installation

Add package to your pubspec:

dependencies:
  flutter_overlay_window: any # or the latest version on Pub
Android

You'll need to add the SYSTEM_ALERT_WINDOW permission and OverlayService to your Android Manifest. Replace explanation_for_special_use with your custom explanation.

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

    <application>
        ...
        <service android:name="flutter.overlay.window.flutter_overlay_window.OverlayService" 
            android:exported="false"
            android:foregroundServiceType="specialUse">
            <property android:name="android.app.PROPERTY_SPECIAL_USE_FGS_SUBTYPE"
                android:value="explanation_for_special_use"/>
        </service>
    </application>
Entry point

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"))
  ));
}

USAGE
 /// check if overlay permission is granted
 final bool status = await FlutterOverlayWindow.isPermissionGranted();

 /// request overlay permission
 /// it will open the overlay settings page and return `true` once the permission granted.
 final bool status = await FlutterOverlayWindow.requestPermission();

  /// Open overLay content
  ///
  /// - Optional arguments:
  ///
  /// `height` the overlay height and default is [WindowSize.fullCover]
  ///
  /// `width` the overlay width and default is [WindowSize.matchParent]
  ///
  /// `alignment` the alignment postion on screen and default is [OverlayAlignment.center]
  ///
  /// `visibilitySecret` the detail displayed in notifications on the lock screen and default is [NotificationVisibility.visibilitySecret]
  ///
  /// `OverlayFlag` the overlay flag and default is [OverlayFlag.defaultFlag]
  ///
  /// `overlayTitle` the notification message and default is "overlay activated"
  ///
  /// `overlayContent` the notification message
  ///
  /// `enableDrag` to enable/disable dragging the overlay over the screen and default is "false"
  ///
  /// `positionGravity` the overlay postion after drag and default is [PositionGravity.none]
  ///
  /// `startPosition` the overlay start position and default is null
 await FlutterOverlayWindow.showOverlay();

 /// closes overlay if open
 await FlutterOverlayWindow.closeOverlay();

 /// broadcast data to and from overlay app
 await FlutterOverlayWindow.shareData("Hello from the other side");

 /// streams message shared between overlay and main app
  FlutterOverlayWindow.overlayListener.listen((event) {
      log("Current Event: $event");
    });

 /// use [OverlayFlag.focusPointer] when you want to use fields that show keyboards
 await FlutterOverlayWindow.showOverlay(flag: OverlayFlag.focusPointer);


 /// update the overlay flag while the overlay in action
 await FlutterOverlayWindow.updateFlag(OverlayFlag.defaultFlag);

 /// Update the overlay size in the screen
 await FlutterOverlayWindow.resizeOverlay(80, 120);

 /// Update the overlay position in the screen
 ///
 /// `position` the new position of the overlay
 ///
 /// `return` true if the position updated successfully
 await FlutterOverlayWindow.moveOverlay(OverlayPosition(0, 156))

 /// Get the current overlay position
 ///
 /// `return` the current overlay position
 await FlutterOverlayWindow.getOverlayPosition()


enum OverlayFlag {
  /// Window flag: this window can never receive touch events.
  /// Usefull if you want to display click-through overlay
  clickThrough,

  /// Window flag: this window won't ever get key input focus
  /// so the user can not send key or other button events to it.
  defaultFlag,

  /// Window flag: allow any pointer events outside of the window to be sent to the windows behind it.
  /// Usefull when you want to use fields that show keyboards.
  focusPointer,
}


  /// Type of dragging behavior for the overlay.
  enum PositionGravity {
    /// The `PositionGravity.none` will allow the overlay to postioned anywhere on the screen.
    none,

    /// The `PositionGravity.right` will allow the overlay to stick on the right side of the screen.
    right,

    /// The `PositionGravity.left` will allow the overlay to stick on the left side of the screen.
    left,

    /// The `PositionGravity.auto` will allow the overlay to stick either on the left or right side of the screen depending on the overlay position.
    auto,
  }


カテゴリー

ソースリポジトリ

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