AlertDialog

Overview

An AlertDialog is used to inform the user about situations that require acknowledgement. It can display an optional title, content, and a list of actions.

  • **Inherits**: DialogControl
  • Properties

  • action_button_padding: Padding around each button in actions. Type: PaddingValue | None.
  • actions: List of Control objects displayed at the bottom. Defaults to an empty list. Raises ValueError if title, content, and actions are all empty.
  • actions_alignment: Horizontal layout for actions. Defaults to MainAxisAlignment.END.
  • actions_overflow_button_spacing: Spacing between actions when they overflow to a column layout.
  • actions_padding: Padding around the actions set. Defaults to zero.
  • alignment: How to align the dialog. Defaults to DialogTheme.alignment or Alignment.CENTER.
  • barrier_color: Color of the modal barrier. Defaults to DialogTheme.barrier_color or Colors.BLACK_54.
  • bgcolor: Background color of the dialog surface. Type: ColorValue | None.
  • clip_behavior: Defines how dialog content is clipped. Defaults to ClipBehavior.NONE.
  • content: The main content of the dialog. Type: Control | None.
  • content_padding: Padding around the content. Defaults to specific values if content exists.
  • content_text_style: Text style for the content. Defaults to theme settings.
  • elevation: Z-coordinate for dialog elevation. Type: Number | None.
  • icon: A control displayed at the top of the dialog. Type: Control | None.
  • icon_color: Color for the icon. Defaults to theme settings.
  • icon_padding: Padding around the icon. Type: PaddingValue | None.
  • inset_padding: Padding around the dialog itself. Defaults to Padding.symmetric(vertical=40, horizontal=24).
  • modal: If True, the dialog cannot be dismissed by clicking outside. Defaults to False.
  • scrollable: If True, title and content are wrapped in a scrollable view. Defaults to False.
  • semantics_label: Semantic label for accessibility. Type: str | None.
  • shadow_color: Color of the drop shadow. Type: ColorValue | None.
  • shape: The shape of the dialog. Defaults to theme settings or RoundedRectangleBorder(radius=4.0).
  • title: The title of the dialog. Type: StrOrControl | None.
  • title_padding: Padding around the title. Defaults to specific values.
  • title_text_style: Text style for the title. TBD.
  • Examples

  • **Basic AlertDialog**: Displays a title, content, and a dismiss button.
  • **Modal and non-modal dialogs**: Demonstrates creating both dismissible and non-dismissible dialogs with actions and alignment.
  • Types

  • PaddingValue: Type alias for padding values.
  • Control: Base class for Flet controls.
  • MainAxisAlignment: Enum for aligning items along the main axis.
  • ColorValue: Type alias for color values.
  • ClipBehavior: Enum for clipping behavior.
  • Alignment: Defines alignment of controls.
  • Number: Type alias for numeric values.
  • TextStyle: Defines text styling properties.
  • OutlinedBorder: Base class for bordered shapes.
  • StrOrControl: Type alias for string or Control.