showAdaptiveDialog<T> function

Future<T?> showAdaptiveDialog<T>(
  1. {required BuildContext context,
  2. required WidgetBuilder builder,
  3. bool? barrierDismissible,
  4. Color? barrierColor,
  5. String? barrierLabel,
  6. bool useSafeArea = true,
  7. bool useRootNavigator = true,
  8. RouteSettings? routeSettings,
  9. Offset? anchorPoint,
  10. TraversalEdgeBehavior? traversalEdgeBehavior}

Displays either a Material or Cupertino dialog depending on platform.

On most platforms this function will act the same as showDialog, except for iOS and macOS, in which case it will act the same as showCupertinoDialog.

On Cupertino platforms, barrierColor, useSafeArea, and traversalEdgeBehavior are ignored.


Future<T?> showAdaptiveDialog<T>({
  required BuildContext context,
  required WidgetBuilder builder,
  bool? barrierDismissible,
  Color? barrierColor,
  String? barrierLabel,
  bool useSafeArea = true,
  bool useRootNavigator = true,
  RouteSettings? routeSettings,
  Offset? anchorPoint,
  TraversalEdgeBehavior? traversalEdgeBehavior,
}) {
  final ThemeData theme = Theme.of(context);
  switch (theme.platform) {
    case TargetPlatform.fuchsia:
    case TargetPlatform.linux:
      return showDialog<T>(
        context: context,
        builder: builder,
        barrierDismissible: barrierDismissible ?? true,
        barrierColor: barrierColor,
        barrierLabel: barrierLabel,
        useSafeArea: useSafeArea,
        useRootNavigator: useRootNavigator,
        routeSettings: routeSettings,
        anchorPoint: anchorPoint,
        traversalEdgeBehavior: traversalEdgeBehavior,
    case TargetPlatform.iOS:
    case TargetPlatform.macOS:
      return showCupertinoDialog<T>(
        context: context,
        builder: builder,
        barrierDismissible: barrierDismissible ?? false,
        barrierLabel: barrierLabel,
        useRootNavigator: useRootNavigator,
        anchorPoint: anchorPoint,
        routeSettings: routeSettings,