show<T> static method

Future<T?> show<T>({
  1. required BuildContext context,
  2. required List<PlatformDialogAction<T>> actions,
  3. String? title,
  4. String? message,
  5. Widget? content,
  6. bool barrierDismissible = true,
  7. Color? barrierColor = Colors.black54,
  8. String? barrierLabel,
  9. bool useSafeArea = true,
  10. bool useRootNavigator = true,
  11. RouteSettings? routeSettings,
  12. Offset? anchorPoint,
  13. dynamic onClose()?,
})

Displays a dialog.

When the dialog is popped, PlatformDialogAction.result is called and its return value becomes the result of the Future.

Implementation

static Future<T?> show<T>({
  required BuildContext context,
  required List<PlatformDialogAction<T>> actions,
  String? title,
  String? message,
  Widget? content,
  bool barrierDismissible = true,
  Color? barrierColor = Colors.black54,
  String? barrierLabel,
  bool useSafeArea = true,
  bool useRootNavigator = true,
  RouteSettings? routeSettings,
  Offset? anchorPoint,
  Function()? onClose,
}) async {
  assert(content != null || message != null);

  return _queue.add<T?>(() {
    if (context.owner == null) {
      return null;
    }

    return showDialog<T>(
      context: context,
      builder: (context) => _PlatformAlertDialog<T>(
        content: content ?? Text(message!),
        actions: actions,
        title: title,
      ),
      barrierDismissible: barrierDismissible,
      barrierColor: barrierColor,
      barrierLabel: barrierLabel,
      useSafeArea: useSafeArea,
      useRootNavigator: useRootNavigator,
      routeSettings: routeSettings,
      anchorPoint: anchorPoint,
    );
  });
}