A simple package to simplify screen management. When loading any async task, this package prevent the user from interacting with the screen until the async task finishes.
Package selection guidance compiled from public package information, community data, and project usage.
LoaderOverlay is a Flutter package that simplifies screen management during asynchronous operations. It displays a loading overlay to prevent user interaction while tasks like API calls or data processing are in progress. The overlay can be easily toggled on and off, ensuring a smooth user experience by blocking input until the task completes. It supports all major platforms including Android, iOS, Web, macOS, Windows, and Linux. Ideal for improving UX during loading states without requiring complex custom implementations.
Use cases
Blocking UI during async operations
Preventing accidental taps during loading
Showing loading indicators in forms
Managing long-running background tasks
Improving app responsiveness
Simplifying loading state handling
Key features
Simple overlay activation
Automatic UI blocking
Cross-platform support
Easy integration with async tasks
Customizable loading appearance
Non-intrusive design
Suitable for
Developers seeking quick loading overlays
Apps with frequent async operations
UIs requiring clear loading feedback
Teams prioritizing UX consistency
Projects needing minimal boilerplate
Considerations
May require manual overlay dismissal
Limited customization options
Potential performance impact with frequent toggling
Not suitable for complex loading animations
Depends on proper async task coordination
Original README
Original README snapshot from the linked source repository. Visit the repository for the latest content.
Introduction
Have you ever found yourself in the situation of doing some async processing your screen and wanting
to prevent the user from interacting with the screen while the application is loading? If so, this
package was made just for you.
Basic Usage
The most simple usage is just wrap the widget that you want an overlay on LoaderOverlay. Default
loader will be shown.
This simple step will already configure the loader overlay for use.
After that configuration you can just call:
context.loaderOverlay.show();
This will show the overlay with the default loading indicator. The default loading configured is to
just show a centered CircularProgressIndicator
To hide the overlay (after the async processing, for example), just call:
context.loaderOverlay.hide();
You can check if overlay is visible:
final isVisible = context.loaderOverlay.visible;
*Note: You will always need the context to show or hide the loader overlay
Basic Usage on Navigation
To use this package with named routes you can just wrap your MaterialApp with GlobalLoaderOverlay.
This widget has all the features of LoaderOverlay but it is provided for all the routes of the app.
Your overlay loader widget can be any widget you want. For example you can import the
package flutter_spinkit and customise your widget like this.
To do that just pass your widget to overlayWidget and set useDefaultLoading to false.
Another customisation you can do is configure the color and opacity of the overlay.
The default opacity is grey with 0.4 opacity, but you can change it with
the overlayColor: Colors.yellow.withValues(alpha: 0.8).
If you pass widget to context.loaderOverlay.show, then defaultLoader and widgetOverlay will be
ignored;
Progress
If you want to show some progress while the loader overlay is visible, you can do it with the
context.loaderOverlay.show(progress: 'Doing progress #0',) for an initial progress, and with
context.loaderOverlay.progress('Doing progress #1'); every time the progress need to change.
Both this methods pass the progress to the current widgetBuilder on every call.
You can also remove by complete the overlayColor (set to transparent), set the useDefaultLoading to false,
and use a fully personalized overlayWidgetBuilder to make your own 100% customizable overlay.
By default, the overlay does not animate in or out. You can enable animations by passing the
appropriate parameters to LoaderOverlay. Internally, an AnimatedSwitcher is used to manage
animations, so the parameters are passed directly to the AnimatedSwitcher. By specifying
a duration and reverseDuration, the overlay will animate in and out using a fade (the default
transition used by AnimatedSwitcher). You can also pass curves, a transition builder and a layout
builder for further customisation.