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.
/// check if overlay permission is grantedfinalbool status = awaitFlutterOverlayWindow.isPermissionGranted();
/// request overlay permission/// it will open the overlay settings page and return `true` once the permission granted.finalbool status = awaitFlutterOverlayWindow.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 nullawaitFlutterOverlayWindow.showOverlay();
/// closes overlay if openawaitFlutterOverlayWindow.closeOverlay();
/// broadcast data to and from overlay appawaitFlutterOverlayWindow.shareData("Hello from the other side");
/// streams message shared between overlay and main appFlutterOverlayWindow.overlayListener.listen((event) {
log("Current Event: $event");
});
/// use [OverlayFlag.focusPointer] when you want to use fields that show keyboardsawaitFlutterOverlayWindow.showOverlay(flag: OverlayFlag.focusPointer);
/// update the overlay flag while the overlay in actionawaitFlutterOverlayWindow.updateFlag(OverlayFlag.defaultFlag);
/// Update the overlay size in the screenawaitFlutterOverlayWindow.resizeOverlay(80, 120);
/// Update the overlay position in the screen////// `position` the new position of the overlay////// `return` true if the position updated successfullyawaitFlutterOverlayWindow.moveOverlay(OverlayPosition(0, 156))
/// Get the current overlay position////// `return` the current overlay positionawaitFlutterOverlayWindow.getOverlayPosition()
enumOverlayFlag {
/// 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.enumPositionGravity {
/// 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,
}