showCupertinoProgressDialog<T> function
Future<ProgressDialogResult<T> >
showCupertinoProgressDialog<T>({
- required BuildContext context,
- required Task<
T> future, - WidgetBuilder? builder,
- Offset? anchorPoint,
- String? barrierLabel,
- Color? barrierColor,
- bool? requestFocus,
Shows a Cupertino-styled progress dialog while executing an asynchronous task.
Displays a modal progress dialog with iOS-style appearance that
remains visible until future completes.
Parameters:
context- The build context used to show the dialogfuture- The async task to execute while showing the progress dialogbuilder- Optional custom widget builder for the progress dialog UIuseRootNavigator- Whether to show dialog above all screens, defaults to trueanchorPoint- Optional anchor point for the dialog positionbarrierLabel- Semantic label used for the modal barrierbarrierColor- Color of the modal barrier behind the dialogrequestFocus- Whether the dialog should request focus when opened
Returns a ProgressDialogResult containing either the successful result value or error details if the future fails.
Example:
final result = await showCupertinoProgressDialog(
context: context,
future: () => myAsyncTask(),
);
switch (result) {
case Success(value: final value):
print('Task completed successfully: $value');
break;
case Failure(error: final error):
print('Task failed: $error');
break;
}
Implementation
Future<ProgressDialogResult<T>> showCupertinoProgressDialog<T>({
required c.BuildContext context,
required Task<T> future,
c.WidgetBuilder? builder,
c.Offset? anchorPoint,
String? barrierLabel,
bool useRootNavigator = true,
c.Color? barrierColor,
bool? requestFocus,
}) async {
final navigator = c.Navigator.of(context, rootNavigator: useRootNavigator);
late final c.CupertinoDialogRoute<ProgressDialogResult<T>> route;
route = c.CupertinoDialogRoute<ProgressDialogResult<T>>(
builder: (context) => ExactlyOnce(
callback: () => _callback(navigator, future, route),
child: builder?.call(context) ?? const CupertinoProgressBarDialog(),
),
context: context,
barrierDismissible: false,
barrierLabel: barrierLabel,
barrierColor: barrierColor,
anchorPoint: anchorPoint,
requestFocus: requestFocus,
);
final result = await navigator.push<ProgressDialogResult<T>>(route);
return result!;
}