CupertinoAlertDialog
An iOS-style alert dialog that informs the user about situations that require acknowledgement.Class signature
Properties
Whether this dialog cannot be dismissed by clicking the area outside of it.
The title of this dialog, displayed in a large font at the top of this dialog.Typically a
Text control.The content of this dialog, displayed in a light font at the center of this dialog.Typically a
Column that contains the dialog’s Text message.A set of actions that are displayed at the bottom of the dialog.Typically this is a list of
CupertinoDialogAction controls.The animation style to be used when the system keyboard intrudes into the space that the dialog is placed in.
The color of the modal barrier below this dialog.If None, then
DialogTheme.barrier_color is used. If that is also None, the default is Colors.BLACK_54.Validation
The dialog requires at least one of the following to be visible:title(as a string or visible Control)content(as a visible Control)- At least one visible action in
actions
ValueError is raised.
iOS-specific behavior
- Actions are arranged horizontally when there are two or fewer actions, vertically when there are more
- The dialog has rounded corners matching iOS design guidelines
- Backdrop blur effect is applied behind the dialog (platform-dependent)
- Keyboard animation uses iOS-standard decelerate curve with 100ms duration
Comparison with Material
- CupertinoAlertDialog uses
CupertinoDialogActionfor actions, Material uses regular buttons - CupertinoAlertDialog has iOS-specific styling with rounded corners and blur effects
- CupertinoAlertDialog automatically arranges actions based on count
- CupertinoDialogAction supports
defaultanddestructivestyling
Examples
Simple confirmation dialog
Destructive action dialog
Multi-option dialog
CupertinoDialogAction
A button used in Cupertino-style dialogs.Class signature
Properties
The content of this action button.Must be either a string or a visible Control.
Whether this action is a default action. In this case, the button will have bold text.Multiple actions can have this property set to True in a CupertinoAlertDialog.
If set to True, this button’s text color will be red.Typically used for actions that destroy objects, such as a delete action that deletes an email.
The text style to use for text in this button.Can be useful when
content is a string.Events
Called when a user clicks this button.
Validation
Thecontent must be either a string or a visible Control. A ValueError is raised if this condition is not met.
Usage notes
- Typically used as a child of
CupertinoAlertDialog.actionsorCupertinoActionSheet.actions - The
defaultproperty adds bold text styling to emphasize the recommended action - The
destructiveproperty adds red text color to warn about dangerous actions - Both
defaultanddestructivecan be used on different actions in the same dialog