showAdaptiveDialog<T> function
- required BuildContext context,
- required WidgetBuilder builder,
- bool? barrierDismissible,
- Color? barrierColor,
- String? barrierLabel,
- bool useSafeArea = true,
- RouteSettings? routeSettings,
- Offset? anchorPoint,
- 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.
Implementation
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.android:
case TargetPlatform.fuchsia:
case TargetPlatform.linux:
case TargetPlatform.windows:
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,
);
}
}