搜索插件、代码仓与 APP 分类

overlay_pop_up 封面
插件详情v1.0.6+6

overlay_pop_up

一个全新的 Flutter 插件,可在 Android 上即使应用已关闭或被终止时,仍能在其他应用之上显示弹窗或屏幕。

Android
近 30 天下载
21
喜欢数
53
Pub 分数
160

安装插件

flutter pub add overlay_pop_up

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

一个 Flutter 插件,可在 Android 上显示弹出窗口或覆盖屏幕,即使应用已关闭或终止。它利用 Android 的系统级覆盖权限,在其他应用之上显示内容,适用于通知、快速操作或持久性 UI 元素。该插件与 Flutter 无缝集成,需要用户授权才能运行。专为 Android 设计,不支持 iOS。开发者可以编程方式自定义覆盖层的外观和行为。

适合场景

  • 显示持久通知
  • 创建浮动操作面板
  • 应用在后台时显示警报
  • 实现快速访问工具
  • 在其他应用中提供实时更新

主要特点

  • 即使应用被终止也能正常工作
  • 仅限 Android 的叠加层支持
  • 可自定义的覆盖内容
  • 系统级权限处理
  • 与 Flutter 的简单集成

适合对象

  • 开发始终开启的 UI 组件的开发者
  • 需要持久覆盖的应用程序
  • 需要前景可见性
  • 通知增强的应用程序
  • 带有浮动界面的实用程序应用

使用建议

  • 需要 Android 系统叠加层权限
  • iOS 上不可用
  • 可能受设备制造商限制
  • 用户必须手动启用权限
  • 可能影响电池和性能

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

overlay_pop_up

A new Flutter plugin to display pop ups or screens over other apps in Android even when app is closed or killed.

Buy Me A Coffee

Demo

Preview

Android

add this to your AndroidManifest.xml

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

 <application>
        ...
        <service
           android:name="com.requiemz.overlay_pop_up.OverlayService"
           android:exported="false" />
    </application>
Android 14

applications that target SDK 34 and use foreground service should include foregroundServiceType attribute(see documentation).

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

 <application>
        ...
        <service
           android:name="com.requiemz.overlay_pop_up.OverlayService"
           android:exported="false"
           <!-- add this -->
           android:foregroundServiceType="camera, dataSync, location, etc" />
    </application>

Flutter implementation

configure your main.dart entry point a widget to display (make sure to add @pragma('vm:entry-point'))

NOTE: Now you can pass as parameter the dart entry point method name when showOverlay is called

@pragma("vm:entry-point")
void overlayPopUp() {
  WidgetsFlutterBinding.ensureInitialized();
  runApp(const MaterialApp(
    debugShowCheckedModeBanner: false,
    home: Text('Hello Pub.dev!'),
  ));
}

Overlay Methods

returns true when overlay permission is alreary granted if permission is not granted then open app settings

await OverlayPopUp.requestPermission();

returns true or false according to permission status

await OverlayPopUp.checkPermission();

display your overlay and return true if is showed

PARAMS

  • height is not required by default is MATCH_PARENT

  • width is not required by default is MATCH_PARENT

  • verticalAlignment is not required by default is CENTER for more info see: https://developer.android.com/reference/android/view/Gravity

  • horizontalAlignment is not required by default is CENTER for more info see: https://developer.android.com/reference/android/view/Gravity

  • backgroundBehavior by default is focusable flag that is you can take focus inside a overlay for example inside a textfield and [tapThrough] you can tap through the overlay background even if has MATCH_PARENT sizes.

  • screenOrientation by default orientation is portrait.

  • closeWhenTapBackButton by default when user presses back button the overlay no has any action if you pass true then back button will close overlay.

  • isDraggable by default is false therefore the overlay can´t be dragged.

  • entryPointMethodName by default is 'overlayPopUp' if you want you can change it

    await OverlayPopUp.showOverlay();
    

    returns true if overlay closed correctly or already is closed

    await OverlayPopUp.closeOverlay();
    

    returns the overlay status true = open, false = closed

    await OverlayPopUp.isActive();
    

    returns the last overlay position if drag is enabled

    await OverlayPopUp.getOverlayPosition();
    

    share dynamic data to overlay

    await OverlayPopUp.sendToOverlay({'data':'hello!'});
    await OverlayPopUp.sendToOverlay('hello');
    

    receive the data from flutter as stream

    await OverlayPopUp.dataListener();
    

所属分类

依赖

依赖清单 1 项

  • plugin_platform_interface^2.1.8

源码仓库

使用此插件的项目

暂无相关数据。