showFutureLoadingDialog<T> function
Displays a loading dialog which reacts to the given future
. The dialog
will be dismissed and the value will be returned when the future completes.
If an error occured, then onError
will be called and this method returns
null. Set title
and backLabel
to controll the look and feel or set
LoadingDialog.defaultTitle, LoadingDialog.defaultBackLabel and
LoadingDialog.defaultOnError to have global preferences.
Implementation
Future<Result<T>> showFutureLoadingDialog<T>({
required BuildContext context,
required Future<T> Function() future,
String? title,
String? backLabel,
String Function(dynamic exception)? onError,
bool barrierDismissible = false,
}) async {
final result = await showAdaptiveDialog<Result<T>>(
context: context,
barrierDismissible: barrierDismissible,
builder: (BuildContext context) => LoadingDialog<T>(
future: future,
title: title,
backLabel: backLabel,
onError: onError,
),
);
return result ??
Result.error(
Exception('FutureDialog canceled'),
StackTrace.current,
);
}