showGeneralDialog<T> function

Future<T> showGeneralDialog <T>({@required BuildContext context, @required RoutePageBuilder pageBuilder, bool barrierDismissible, String barrierLabel, Color barrierColor, Duration transitionDuration, RouteTransitionsBuilder transitionBuilder })

Displays a dialog above the current contents of the app.

This function allows for customization of aspects of the dialog popup.

This function takes a pageBuilder which is used to build the primary content of the route (typically a dialog widget). Content below the dialog is dimmed with a ModalBarrier. The widget returned by the pageBuilder does not share a context with the location that showGeneralDialog is originally called from. Use a StatefulBuilder or a custom StatefulWidget if the dialog needs to update dynamically. The pageBuilder argument can not be null.

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 barrierDismissible argument is used to determine whether this route can be dismissed by tapping the modal barrier. This argument defaults to true. If barrierDismissible is true, a non-null barrierLabel must be provided.

The barrierLabel argument is the semantic label used for a dismissible barrier. This argument defaults to "Dismiss".

The barrierColor argument is the color used for the modal barrier. This argument defaults to Color(0x80000000).

The transitionDuration argument is used to determine how long it takes for the route to arrive on or leave off the screen. This argument defaults to 200 milliseconds.

The transitionBuilder argument is used to define how the route arrives on and leaves off the screen. By default, the transition is a linear fade of the page's contents.

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

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).

See also:

Implementation

Future<T> showGeneralDialog<T>({
  @required BuildContext context,
  @required RoutePageBuilder pageBuilder,
  bool barrierDismissible,
  String barrierLabel,
  Color barrierColor,
  Duration transitionDuration,
  RouteTransitionsBuilder transitionBuilder,
}) {
  assert(pageBuilder != null);
  assert(!barrierDismissible || barrierLabel != null);
  return Navigator.of(context, rootNavigator: true).push(_DialogRoute<T>(
    pageBuilder: pageBuilder,
    barrierDismissible: barrierDismissible,
    barrierLabel: barrierLabel,
    barrierColor: barrierColor,
    transitionDuration: transitionDuration,
    transitionBuilder: transitionBuilder,
  ));
}