simple_loading_dialog 0.1.0 simple_loading_dialog: ^0.1.0 copied to clipboard
A simple full-screen loading dialog for Flutter.
simple_loading_dialog #
A simple full-screen loading dialog for Flutter.
Features #
- A very simple full-screen loading dialog.
- Can block user input while waiting for a Future to complete.
- Rethrows exceptions on error.
- Customizable dialog appearance.
- Returns the result of the Future.
Usage #
To use this package, add simple_loading_dialog as a dependency in your pubspec.yaml file.
Showing the dialog #
To show the dialog, use the showSimpleLoadingDialog function.
final result = showSimpleLoadingDialog<String>(
context: context,
future: myFutureFunction,
);
This will show a full-screen loading dialog while waiting for the myFutureFunction to complete.
Customizing the appearance #
The appearance of the dialog can be customized by passing a dialogBuilder.
showSimpleLoadingDialog<void>(
context: context,
future: myFutureFunction,
dialogBuilder: (context) => AlertDialog(
content: Column(
mainAxisSize: MainAxisSize.min,
children: [
CircularProgressIndicator(),
SizedBox(height: 16),
Text('Custom message'),
],
),
),
);
Handling errors #
If an error occurs while waiting for the Future to complete, the exception will be rethrown. To handle the error, use a try-catch block.
try {
await showSimpleLoadingDialog<void>(
context: context,
future: myFutureFunction,
);
} catch (e) {
// Handle the error.
}
License #
This package is licensed under the MIT License. See the LICENSE file for details.