future<T> static method
Future
future<T>(
- BuildContext context, {
- required Future future,
- OnProgressError? onProgressError,
- OnProgressFinish? onProgressFinish,
- OnProgressCancel? onProgressCancel,
- Color? backgroundColor,
- double? blur,
- Function? onDismiss,
- bool? dismissable,
- Widget? loadingWidget,
- DialogTransitionType? dialogTransitionType,
- Duration? transitionDuration,
- bool useSafeArea = true,
future function let you show ProgressDialog until future (param) reach the end of its action
Implementation
static Future future<T>(
BuildContext context, {
required Future future,
OnProgressError? onProgressError,
OnProgressFinish? onProgressFinish,
OnProgressCancel? onProgressCancel,
Color? backgroundColor,
double? blur,
Function? onDismiss,
bool? dismissable,
Widget? loadingWidget,
DialogTransitionType? dialogTransitionType,
Duration? transitionDuration,
bool useSafeArea = true,
}) async {
CustomProgressDialog pDialog = CustomProgressDialog(
context,
loadingWidget: loadingWidget,
dismissable: dismissable,
backgroundColor: backgroundColor,
blur: blur,
onDismiss: onDismiss,
onCancel: onProgressCancel != null ? onProgressCancel : null,
dialogTransitionType: dialogTransitionType,
transitionDuration: transitionDuration,
);
pDialog.show(useSafeArea: useSafeArea);
var output;
try {
await future.then((data) {
if (onProgressFinish != null)
onProgressFinish = onProgressFinish!(data);
output = data;
}).catchError((error) {
if (onProgressError != null) onProgressError = onProgressError!(error);
});
} catch (e) {}
pDialog.dismiss();
return output;
}