CupertinoAlertDialog class Null safety

An iOS-style alert dialog.

An alert dialog informs the user about situations that require acknowledgement. An alert dialog has an optional title, optional content, and an optional list of actions. The title is displayed above the content and the actions are displayed below the content.

This dialog styles its title and content (typically a message) to match the standard iOS title and message dialog text style. These default styles can be overridden by explicitly defining TextStyles for Text widgets that are part of the title or content.

To display action buttons that look like standard iOS dialog buttons, provide CupertinoDialogActions for the actions given to this dialog.

Typically passed as the child widget to showDialog, which displays the dialog.

This sample shows how to use a CupertinoAlertDialog. The CupertinoAlertDialog shows an alert with a set of two choices when CupertinoButton is pressed.
class MyStatefulWidget extends StatefulWidget {
  const MyStatefulWidget({Key? key}) : super(key: key);

  State<MyStatefulWidget> createState() => _MyStatefulWidgetState();

class _MyStatefulWidgetState extends State<MyStatefulWidget> {
  Widget build(BuildContext context) {
    return CupertinoPageScaffold(
      child: Center(
        child: CupertinoButton(
          onPressed: () {
              context: context,
              builder: (BuildContext context) => CupertinoAlertDialog(
                title: const Text('Alert'),
                content: const Text('Proceed with destructive action?'),
                actions: <CupertinoDialogAction>[
                    child: const Text('No'),
                    onPressed: () {
                    child: const Text('Yes'),
                    isDestructiveAction: true,
                    onPressed: () {
                      // Do something destructive.
          child: const Text('CupertinoAlertDialog'),

See also:



CupertinoAlertDialog({Key? key, Widget? title, Widget? content, List<Widget> actions, ScrollController? scrollController, ScrollController? actionScrollController, Duration insetAnimationDuration, Curve insetAnimationCurve})
Creates an iOS-style alert dialog. [...]


actions List<Widget>
The (optional) set of actions that are displayed at the bottom of the dialog. [...]
actionScrollController ScrollController?
A scroll controller that can be used to control the scrolling of the actions in the dialog. [...]
content Widget?
The (optional) content of the dialog is displayed in the center of the dialog in a lighter font. [...]
hashCode int
The hash code for this object. [...]
@nonVirtual, read-only, inherited
insetAnimationCurve Curve
The curve to use for the animation shown when the system keyboard intrudes into the space that the dialog is placed in. [...]
insetAnimationDuration Duration
The duration of the animation to show when the system keyboard intrudes into the space that the dialog is placed in. [...]
key Key?
Controls how one widget replaces another widget in the tree. [...]
final, inherited
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited
scrollController ScrollController?
A scroll controller that can be used to control the scrolling of the content in the dialog. [...]
title Widget?
The (optional) title of the dialog is displayed in a large font at the top of the dialog. [...]


build(BuildContext context) Widget
Describes the part of the user interface represented by this widget. [...]
createElement() StatelessElement
Creates a StatelessElement to manage this widget's location in the tree. [...]
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children. [...]
@protected, inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node. [...]
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep. [...]
toString({DiagnosticLevel minLevel =}) String
A string representation of this object. [...]
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a string representation of this node and its descendants. [...]
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a one-line detailed description of the object. [...]
toStringShort() String
A short, textual description of this widget.


operator ==(Object other) bool
The equality operator. [...]
@nonVirtual, inherited