showCupertinoDialog<T> function

Future<T> showCupertinoDialog<T>(
  1. {@required BuildContext context,
  2. @required WidgetBuilder builder,
  3. bool useRootNavigator = true}

Displays an iOS-style dialog above the current contents of the app, with iOS-style entrance and exit animations, modal barrier color, and modal barrier behavior (the dialog is not dismissible with a tap on the barrier).

This function takes a builder which typically builds a CupertinoDialog or CupertinoAlertDialog widget. Content below the dialog is dimmed with a ModalBarrier. The widget returned by the builder does not share a context with the location that showCupertinoDialog is originally called from. Use a StatefulBuilder or a custom StatefulWidget if the dialog needs to update dynamically.

The context argument is used to look up the Navigator for the dialog. It is only used when the method is called. Its corresponding widget can be safely removed from the tree before the dialog is closed.

The useRootNavigator argument is used to determine whether to push the dialog to the Navigator furthest from or nearest to the given context. By default, useRootNavigator is true and the dialog route created by this method is pushed to the root navigator.

If the application has multiple Navigator objects, it may be necessary to call Navigator.of(context, rootNavigator: true).pop(result) to close the dialog rather than just Navigator.pop(context, result).

Returns a Future that resolves to the value (if any) that was passed to Navigator.pop when the dialog was closed.

See also:


Future<T> showCupertinoDialog<T>({
  @required BuildContext context,
  @required WidgetBuilder builder,
  bool useRootNavigator = true,
}) {
  assert(builder != null);
  assert(useRootNavigator != null);
  return showGeneralDialog(
    context: context,
    barrierDismissible: false,
    barrierColor: CupertinoDynamicColor.resolve(_kModalBarrierColor, context),
    // This transition duration was eyeballed comparing with iOS
    transitionDuration: const Duration(milliseconds: 250),
    pageBuilder: (BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation) {
      return builder(context);
    transitionBuilder: _buildCupertinoDialogTransitions,
    useRootNavigator: useRootNavigator,