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.
Demo
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>
Flutter implementation
configure your main.dart entry point a widget to display (make sure to add @pragma('vm:entry-point'))
@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
-
heightis not required by default is MATCH_PARENT -
widthis not required by default is MATCH_PARENT -
verticalAlignmentis not required by default is CENTER for more info see: developer.android.com/reference/android/view/Gravity -
horizontalAlignmentis not required by default is CENTER for more info see: developer.android.com/reference/android/view/Gravity -
backgroundBehaviorby default is focusable flag that is you can take focus inside a overlay for example inside a textfield andtapThroughyou can tap through the overlay background even if has MATCH_PARENT sizes. -
screenOrientationby default orientation is portrait. -
closeWhenTapBackButtonby default when user presses back button the overlay no has any action if you pass true then back button will close overlay. -
isDraggableby default is false therefore the overlay can“t be dragged.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.showOverlay({'data':'hello!'}); await OverlayPopUp.showOverlay('hello');receive the data from flutter as stream
await OverlayPopUp.dataListener();

