This project demonstrates how to implement different types of overlay widgets in Flutter. I created this to explore the Overlay widget's capabilities and to have a reference for future projects that need popup notifications, modal dialogs, or loading screens.
The app includes three different overlay examples:
-
Push Notification Style - A card that slides in from the top, perfect for displaying follow notifications, messages, or alerts. Auto-dismisses after 3 seconds.
-
Confirmation Dialog - A centered modal popup with confirm/cancel buttons. Great for delete actions or other destructive operations that need user confirmation.
-
Loading Overlay - A full-screen loading indicator that blocks user interaction. Useful during API calls or file processing.
- Using
OverlayEntryto create custom overlay content - Positioning overlays with
Positionedwidget - Inserting overlays into the widget tree with
Overlay.of(context).insert() - Proper cleanup and removal of overlay entries
- Creating semi-transparent background overlays
flutter pub get
flutter runTap the buttons to see each overlay type in action. The notification will auto-dismiss, while the dialog and loading screen can be dismissed by tapping the close button or waiting for the timeout.
Each overlay is built using OverlayEntry with a custom builder function. The overlays are inserted into the app's overlay stack and removed either automatically (with Future.delayed) or manually when the user interacts with them.
This approach is more flexible than using showDialog() or ScaffoldMessenger because you have complete control over positioning, styling, and behavior.
Planning to add more overlay patterns like:
- Toast notifications
- Action sheets
- Custom tooltips
- Multi-step overlays
Feel free to use this code as a starting point for your own overlay implementations!
