AlertDialog.adaptive constructor

const AlertDialog.adaptive(
  1. {Key? key,
  2. Widget? icon,
  3. EdgeInsetsGeometry? iconPadding,
  4. Color? iconColor,
  5. Widget? title,
  6. EdgeInsetsGeometry? titlePadding,
  7. TextStyle? titleTextStyle,
  8. Widget? content,
  9. EdgeInsetsGeometry? contentPadding,
  10. TextStyle? contentTextStyle,
  11. List<Widget>? actions,
  12. EdgeInsetsGeometry? actionsPadding,
  13. MainAxisAlignment? actionsAlignment,
  14. OverflowBarAlignment? actionsOverflowAlignment,
  15. VerticalDirection? actionsOverflowDirection,
  16. double? actionsOverflowButtonSpacing,
  17. EdgeInsetsGeometry? buttonPadding,
  18. Color? backgroundColor,
  19. double? elevation,
  20. Color? shadowColor,
  21. Color? surfaceTintColor,
  22. String? semanticLabel,
  23. EdgeInsets insetPadding,
  24. Clip clipBehavior,
  25. ShapeBorder? shape,
  26. AlignmentGeometry? alignment,
  27. bool scrollable,
  28. ScrollController? scrollController,
  29. ScrollController? actionScrollController,
  30. Duration insetAnimationDuration,
  31. Curve insetAnimationCurve}

Creates an adaptive AlertDialog based on whether the target platform is iOS or macOS, following Material design's Cross-platform guidelines.

On iOS and macOS, this constructor creates a CupertinoAlertDialog. On other platforms, this creates a Material design AlertDialog.

Typically passed as a child of showAdaptiveDialog, which will display the alert differently based on platform.

If a CupertinoAlertDialog is created only these parameters are used: title, content, actions, scrollController, actionScrollController, insetAnimationDuration, and insetAnimationCurve. If a material AlertDialog is created, scrollController, actionScrollController, insetAnimationDuration, and insetAnimationCurve are ignored.

The target platform is based on the current Theme: ThemeData.platform.

This demo shows a TextButton which when pressed, calls showAdaptiveDialog. When called, this method displays an adaptive dialog above the current contents of the app, with different behaviors depending on target platform.

CupertinoDialogAction is conditionally used as the child to show more platform specific design.


To create a local project with this code sample, run:
flutter create --sample=material.AlertDialog.adaptive.1 mysample


const factory AlertDialog.adaptive({
  Key? key,
  Widget? icon,
  EdgeInsetsGeometry? iconPadding,
  Color? iconColor,
  Widget? title,
  EdgeInsetsGeometry? titlePadding,
  TextStyle? titleTextStyle,
  Widget? content,
  EdgeInsetsGeometry? contentPadding,
  TextStyle? contentTextStyle,
  List<Widget>? actions,
  EdgeInsetsGeometry? actionsPadding,
  MainAxisAlignment? actionsAlignment,
  OverflowBarAlignment? actionsOverflowAlignment,
  VerticalDirection? actionsOverflowDirection,
  double? actionsOverflowButtonSpacing,
  EdgeInsetsGeometry? buttonPadding,
  Color? backgroundColor,
  double? elevation,
  Color? shadowColor,
  Color? surfaceTintColor,
  String? semanticLabel,
  EdgeInsets insetPadding,
  Clip clipBehavior,
  ShapeBorder? shape,
  AlignmentGeometry? alignment,
  bool scrollable,
  ScrollController? scrollController,
  ScrollController? actionScrollController,
  Duration insetAnimationDuration,
  Curve insetAnimationCurve,
}) = _AdaptiveAlertDialog;