elegant_loading_overlay 0.0.2
elegant_loading_overlay: ^0.0.2 copied to clipboard
Beautiful, customizable loading overlay for Flutter with one-line API.
elegant_loading_overlay #
Beautiful, customizable loading overlay for Flutter with a one-line API. Features 11 built-in loaders, smooth animations, progress indicators, blur backgrounds, theme support, and full platform compatibility.
β¨ Features #
- π One-line API β
LoadingOverlay.show()/LoadingOverlay.hide() - π¨ 11 Built-in Loaders β Circular, Dots, Pulse, Ripple, Bars, Cube, Ring, Gradient Spinner, Minimal Spinner, Material Spinner, Cupertino Spinner
- π¬ Smooth Animations β Fade, Scale, Slide, Zoom, Rotation
- π«οΈ Blur Background β Configurable blur sigma
- π Progress Indicators β Determinate and indeterminate
- π¬ Messages & Subtitles β Customizable text content
- π― Custom Builder β Full control with custom widgets
- π Theme Support β
LoadingOverlayThemefor consistent styling - π Stacking Protection β Only one overlay at a time
- βΏ Accessibility β Full semantics support
- π Cross-Platform β Android, iOS, Web, macOS, Windows, Linux
- π Dark Mode β Fully supported
- π± Responsive β Mobile, Tablet, Desktop
- β‘ Performant β RepaintBoundary, ValueNotifier, const widgets
- π§ͺ Well Tested β Comprehensive widget and unit tests
- π¦ Zero Dependencies β Flutter SDK only
π¦ Installation #
Add to your pubspec.yaml:
dependencies:
elegant_loading_overlay: ^0.0.1
Then run:
flutter pub get
π Quick Start #
import 'package:elegant_loading_overlay/elegant_loading_overlay.dart';
// Show
LoadingOverlay.show(context: context);
// Hide
await LoadingOverlay.hide();
π Usage #
Basic Loading #
LoadingOverlay.show(context: context);
await doSomeWork();
await LoadingOverlay.hide();
With Message #
LoadingOverlay.show(
context: context,
message: 'Loading...',
);
With Message & Subtitle #
LoadingOverlay.show(
context: context,
message: 'Uploading file',
subtitle: 'This may take a moment',
);
With Progress #
LoadingOverlay.show(
context: context,
message: 'Downloading...',
progress: 0.45,
);
Dismissible #
LoadingOverlay.show(
context: context,
dismissible: true,
onDismiss: () => print('Dismissed!'),
);
Check Status & Toggle #
if (LoadingOverlay.isShowing) {
await LoadingOverlay.hide();
}
// Or toggle
await LoadingOverlay.toggle(context: context);
Custom Animation #
LoadingOverlay.show(
context: context,
animation: LoadingAnimationType.scale,
animationDuration: const Duration(milliseconds: 400),
animationCurve: Curves.easeOutBack,
);
Different Loaders #
// Dots loader
LoadingOverlay.show(
context: context,
loaderType: LoaderType.dots,
);
// Pulse loader
LoadingOverlay.show(
context: context,
loaderType: LoaderType.pulse,
);
// Ripple loader
LoadingOverlay.show(
context: context,
loaderType: LoaderType.ripple,
);
// ... and 8 more!
Custom Loader (Builder) #
LoadingOverlay.show(
context: context,
builder: (_) => const Column(
mainAxisSize: MainAxisSize.min,
children: [
Icon(Icons.cloud_upload, size: 48, color: Colors.blue),
SizedBox(height: 16),
Text('Uploading...'),
],
),
);
Blur & Styling #
LoadingOverlay.show(
context: context,
enableBlur: true,
blurSigma: 5.0,
barrierColor: Colors.black54,
backgroundColor: Colors.white,
loaderColor: Colors.teal,
borderRadius: BorderRadius.circular(20),
elevation: 12,
);
Context Extensions #
// Show
context.showLoadingOverlay(message: 'Loading...');
// Hide
context.hideLoadingOverlay();
π¨ Theming #
Wrap your app with LoadingOverlayTheme for consistent styling:
LoadingOverlayTheme(
data: LoadingOverlayThemeData(
loaderColor: Colors.tealAccent,
backgroundColor: Colors.grey.shade900,
messageTextStyle: const TextStyle(
color: Colors.white,
fontSize: 16,
),
blurSigma: 5.0,
animationDuration: const Duration(milliseconds: 400),
animationType: LoadingAnimationType.scale,
loaderType: LoaderType.gradientSpinner,
),
child: MaterialApp(
home: MyHomePage(),
),
)
π§ Scoped Overlays #
Use LoadingOverlayScope for independent overlay control in different parts of your app:
LoadingOverlayScope(
theme: const LoadingOverlayThemeData(
loaderColor: Colors.purple,
),
child: MyPage(),
)
// In MyPage:
final scope = LoadingOverlayScope.of(context);
scope.show();
await scope.hide();
π¬ Available Animations #
| Animation | Description |
|---|---|
fade |
Smooth fade-in/fade-out (default) |
scale |
Grows from center with bounce |
slide |
Slides up from bottom |
zoom |
Scale + fade combination |
rotation |
Spins into view |
none |
Instant, no animation |
π‘ Built-in Loaders #
| Loader | Description |
|---|---|
circular |
Rotating arc spinner (default) |
dots |
Bouncing wave dots |
pulse |
Pulsing circle |
ripple |
Expanding ripple rings |
bars |
Equalizer-style bars |
cube |
Rotating 3D cube |
ring |
Spinning ring with gap |
gradientSpinner |
Gradient arc spinner |
minimalSpinner |
Thin line spinner |
materialSpinner |
Material CircularProgressIndicator |
cupertinoSpinner |
iOS CupertinoActivityIndicator |
π API Reference #
LoadingOverlay (Static API) #
| Method | Description |
|---|---|
show({required context, ...}) |
Show the overlay |
hide() |
Hide the overlay |
toggle({context, ...}) |
Toggle visibility |
isShowing |
Check if overlay is visible |
of(context) |
Get theme data from context |
controller |
Access global controller |
LoadingOverlayConfig #
All configuration options for show():
| Parameter | Type | Default |
|---|---|---|
message |
String? |
null |
subtitle |
String? |
null |
progress |
double? |
null |
dismissible |
bool |
false |
animationType |
LoadingAnimationType |
fade |
animationDuration |
Duration |
300ms |
animationCurve |
Curve |
easeInOut |
barrierColor |
Color |
Colors.black54 |
backgroundColor |
Color |
Colors.white |
loaderColor |
Color |
Colors.blue |
blurSigma |
double |
3.0 |
enableBlur |
bool |
true |
borderRadius |
BorderRadius |
16.0 |
padding |
EdgeInsets |
32.0 |
spacing |
double |
16.0 |
loaderSize |
double |
48.0 |
elevation |
double |
8.0 |
loaderType |
LoaderType |
circular |
builder |
WidgetBuilder? |
null |
onDismiss |
VoidCallback? |
null |
π Platform Support #
| Platform | Supported |
|---|---|
| Android | β |
| iOS | β |
| Web | β |
| macOS | β |
| Windows | β |
| Linux | β |
β‘ Performance Notes #
- Uses
RepaintBoundaryto isolate overlay repaints ValueNotifier-based controller avoids stream overheadconstconstructors used throughoutCustomPainter-based loaders for efficient rendering- Stacking protection prevents duplicate overlay creation
β FAQ #
Q: Can I show multiple overlays at once?
A: The global LoadingOverlay API enforces single-overlay mode. Use LoadingOverlayScope for independent overlays in different subtrees.
Q: What happens if I call hide() without calling show()?
A: Nothing. The method safely returns without error.
Q: What happens if I call show() twice?
A: The existing overlay is updated with the new configuration β no duplicate overlay is created.
Q: Does it work with Navigator.push?
A: Yes. The overlay is inserted into the root Overlay and appears above all routes.
Q: Does it support keyboard avoidance? A: Yes. The overlay content is properly positioned to avoid keyboard overlap.
πΊοΈ Roadmap #
- β Shimmer effect loader
- β Lottie animation support
- β Progress stream support
- β Global configuration
- β Timeout with auto-dismiss
- β Success/Error state transitions
- β Haptic feedback option
- β Sound effect option
π€ Contributing #
Contributions are welcome! Please read our Contributing Guide and Code of Conduct first.
π License #
This project is licensed under the MIT License β see the LICENSE file for details.