Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nsneruno/loading_alert_dialog
Customizable Flutter Alert Dialog that allows running a computation while blocking the app like a normal showDialog.
https://github.com/nsneruno/loading_alert_dialog
alertdialog dart-library flutter flutter-package flutter-plugin showdialog
Last synced: 21 days ago
JSON representation
Customizable Flutter Alert Dialog that allows running a computation while blocking the app like a normal showDialog.
- Host: GitHub
- URL: https://github.com/nsneruno/loading_alert_dialog
- Owner: nsNeruno
- License: mit
- Created: 2019-12-12T07:21:23.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2021-09-16T13:27:42.000Z (over 3 years ago)
- Last Synced: 2024-10-22T10:58:47.962Z (2 months ago)
- Topics: alertdialog, dart-library, flutter, flutter-package, flutter-plugin, showdialog
- Language: Dart
- Size: 24.4 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# loading_alert_dialog [![Pub](https://img.shields.io/pub/v/loading_alert_dialog.svg)](https://pub.dartlang.org/packages/loading_alert_dialog)
Customizable AlertDialog that allows running a computation while blocking the app like a normal showDialog without using the approach of using a [Stack](https://api.flutter.dev/flutter/widgets/Stack-class.html)/[Overlay](https://api.flutter.dev/flutter/widgets/Overlay-class.html) widget.
## Getting Started
This package exposes static methods through one class _**LoadingAlertDialog**_ which are:
* _**showLoadingAlertDialog**_
The main method that works as a wrapper to _showDialog_/_showCupertinoDialog_, where it is controller through a _**Future**_, provided through _**computation**_ argument. When the provided Future completes, with a result or an error, then the "Dialog" will be dismissed on it's own, and the method call itself will return the value of the computation Future itself or throws if the Future throws.
* _**setDefaultWidgetBuilder**_
By setting a WidgetBuilder here, each call to showLoadingAlertDialog won't require to provide _**builder**_ argument.### How-to-use example:
```dart
import 'package:loading_alert_dialog/loading_alert_dialog.dart';LoadingAlertDialog.showLoadingAlertDialog(
context: context,
builder: (context,) => Card(
child: Padding(
padding: const EdgeInsets.all(24.0,),
child: Column(
children: [
CircularProgressIndicator(),
Text("Please Wait...",),
],
mainAxisSize: MainAxisSize.min,
),
),
color: Colors.white,
),
computation: Future.delayed(
Duration(seconds: 3,), () {
final randomNumber = Random().nextInt(300,);
return randomNumber;
},
),
).then((number) {
if (number != null) {
setState(() {
_randomNumber = number;
}
},
);
```
The builder may returns any Widget eligible to be used as an "AlertDialog". The sample code above shows a simple Card with a Text and CircularProgressIndicator for 3 seconds, then pops out a random number, closing the "AlertDialog", then displaying the popped number into the view.