pub struct AlertDialog {Show 28 fields
pub key: Option<KeyRef>,
pub icon: Option<WidgetRef>,
pub icon_color: Option<Color>,
pub icon_padding: Option<EdgeInsetsGeometry>,
pub title: Option<WidgetRef>,
pub title_padding: Option<EdgeInsetsGeometry>,
pub title_text_style: Option<TextStyle>,
pub content: Option<WidgetRef>,
pub content_padding: Option<EdgeInsetsGeometry>,
pub content_text_style: Option<TextStyle>,
pub actions: Option<Vec<WidgetRef>>,
pub actions_padding: Option<EdgeInsetsGeometry>,
pub actions_alignment: Option<MainAxisAlignment>,
pub actions_overflow_alignment: Option<OverflowBarAlignment>,
pub actions_overflow_direction: Option<VerticalDirection>,
pub actions_overflow_button_spacing: Option<f64>,
pub button_padding: Option<EdgeInsetsGeometry>,
pub background_color: Option<Color>,
pub elevation: Option<f64>,
pub shadow_color: Option<Color>,
pub surface_tint_color: Option<Color>,
pub semantic_label: Option<String>,
pub inset_padding: Option<EdgeInsets>,
pub clip_behavior: Option<Clip>,
pub shape: Option<ShapeBorderRef>,
pub alignment: Option<AlignmentGeometry>,
pub constraints: Option<BoxConstraints>,
pub scrollable: bool,
/* private fields */
}Expand description
A Material Design alert dialog.
An alert dialog (also known as a basic dialog) informs the user about situations that require acknowledgment. An alert dialog has an optional title and an optional list of actions. The title is displayed above the content and the actions are displayed below the content.
If the content is too large to fit on the screen vertically, the dialog will
display the title and the actions and let the content overflow, which is
rarely desired. Consider using a scrolling widget for
content, such as SingleChildScrollView, to avoid
overflow. (However, be aware that since AlertDialog tries to size itself
using the intrinsic dimensions of its children, widgets such as ListView,
GridView, and CustomScrollView, which use lazy viewports, will not work.
If this is a problem, consider using Dialog directly.)
For dialogs that offer the user a choice between several options, consider
using a SimpleDialog.
Typically passed as the child widget to ShowDialog, which displays the
dialog.
One set of setters serves both of Dart’s constructors, AlertDialog::new and
AlertDialog::adaptive.
See also:
SimpleDialog, which handles the scrolling of the contents but has noactions.Dialog, on whichAlertDialogandSimpleDialogare based.CupertinoAlertDialog, an iOS-styled alert dialog.ShowDialog, which actually displays the dialog and returns its result.- https://material.io/design/components/dialogs.html#alert-dialog
Fields§
§key: Option<KeyRef>§icon: Option<WidgetRef>An optional icon to display at the top of the dialog.
Typically, an Icon widget. Providing an icon centers the
title’s text.
icon_color: Option<Color>Color for the Icon in the icon of this AlertDialog.
If null, DialogThemeData::icon_color is used. If that is null, defaults to
color scheme’s ColorScheme::secondary if ThemeData::use_material3 is
true, black otherwise.
icon_padding: Option<EdgeInsetsGeometry>Padding around the icon.
If there is no icon, no padding will be provided. Otherwise,
this padding is used.
This property defaults to providing 24 pixels on the top, left, and right
of the icon. If title is not null, 16 pixels of
bottom padding is added to separate the icon from the
title. If the title is null but
content is not null, then no bottom padding is added. If both
the title and content are null, 24 pixels of padding are added to the bottom.
title: Option<WidgetRef>The (optional) title of the dialog is displayed in a large font at the top
of the dialog, below the (optional) icon.
Typically a Text widget.
title_padding: Option<EdgeInsetsGeometry>Padding around the title.
If there is no title, no padding will be provided. Otherwise, this padding is used.
This property defaults to providing 24 pixels on the top, left, and right
of the title. If the content is not null, then no bottom padding
is provided (but see content_padding). If it is null,
then an extra 20 pixels of bottom padding is added to separate the
title from the actions.
title_text_style: Option<TextStyle>Style for the text in the title of this AlertDialog.
If null, DialogThemeData::title_text_style is used. If that’s null,
defaults to TextTheme::headline_small of ThemeData::text_theme if
ThemeData::use_material3 is true, TextTheme::title_large otherwise.
content: Option<WidgetRef>The (optional) content of the dialog is displayed in the center of the dialog in a lighter font.
Typically this is a SingleChildScrollView that contains the dialog’s
message. As noted in the AlertDialog documentation, it’s important
to use a SingleChildScrollView if there’s any risk that the content
will not fit, as the contents will otherwise overflow the dialog.
The horizontal dimension of this widget is defined by the
IntrinsicWidth widget. As a result, the content cannot use
lazy-loading widgets such as ListView, GridView, or
CustomScrollView without being given a fixed width.
content_padding: Option<EdgeInsetsGeometry>Padding around the content.
If there is no content, no padding will be provided. Otherwise, padding of 20 pixels is provided above the content to separate the content from the title, and padding of 24 pixels is provided on the left, right, and bottom to separate the content from the other edges of the dialog.
If ThemeData::use_material3 is true, the top padding separating the
content from the title defaults to 16 pixels instead of 20 pixels.
content_text_style: Option<TextStyle>Style for the text in the content of this AlertDialog.
If null, DialogThemeData::content_text_style is used. If that’s null,
defaults to TextTheme::body_medium of ThemeData::text_theme if
ThemeData::use_material3 is true, TextTheme::title_medium otherwise.
actions: Option<Vec<WidgetRef>>The (optional) set of actions that are displayed at the bottom of the
dialog with an OverflowBar.
Typically this is a list of TextButton widgets. It is recommended to
set the Text::text_align to TextAlign::End for the Text within the
TextButton, so that buttons whose labels wrap to an extra line align
with the overall OverflowBar’s alignment within the dialog.
If the title is not null but the content is
null, then an extra 20 pixels of padding is added above the OverflowBar to
separate the title from the actions.
actions_padding: Option<EdgeInsetsGeometry>Padding around the set of actions at the bottom of the dialog.
Typically used to provide padding to the button bar between the button bar and the edges of the dialog.
The button_padding may contribute to the padding on the
edges of actions as well.
If there are no actions, then no padding will be included.
actions_alignment: Option<MainAxisAlignment>Defines the horizontal layout of the actions according to the
same rules as for Row::main_axis_alignment.
This parameter is passed along to the dialog’s OverflowBar.
If this parameter is null (the default) then MainAxisAlignment::End
is used.
actions_overflow_alignment: Option<OverflowBarAlignment>The horizontal alignment of actions within the vertical
“overflow” layout.
If the dialog’s actions do not fit into a single row, then they
are arranged in a column. This parameter controls the horizontal
alignment of widgets in the case of an overflow.
If this parameter is null (the default) then OverflowBarAlignment::End
is used.
actions_overflow_direction: Option<VerticalDirection>The vertical direction of actions if the children overflow
horizontally.
If the dialog’s actions do not fit into a single row, then they
are arranged in a column. The first action is at the top of the
column if this property is set to VerticalDirection::Down, since it
“starts” at the top and “ends” at the bottom. On the other hand,
the first action will be at the bottom of the column if this
property is set to VerticalDirection::Up, since it “starts” at the
bottom and “ends” at the top.
The spacing between actions when the OverflowBar switches to
a column layout because the actions don’t fit horizontally.
If the widgets in actions do not fit into a single row, they are
arranged into a column. This parameter provides additional vertical space
between buttons when it does overflow.
The padding that surrounds each button in actions.
This is different from actions_padding, which defines
the padding between the entire button bar and the edges of the dialog.
If this property is null, then it will default to 8.0 logical pixels on the left and right.
background_color: Option<Color>§elevation: Option<f64>See Dialog::elevation.
shadow_color: Option<Color>See Dialog::shadow_color.
surface_tint_color: Option<Color>§semantic_label: Option<String>The semantic label of the dialog used by accessibility frameworks to announce screen transitions when the dialog is opened and closed.
In iOS, if this label is not provided, a semantic label will be inferred
from the title if it is not null.
In Android, if this label is not provided, the dialog will use the
MaterialLocalizations::alert_dialog_label as its label.
inset_padding: Option<EdgeInsets>§clip_behavior: Option<Clip>§shape: Option<ShapeBorderRef>See Dialog::shape.
alignment: Option<AlignmentGeometry>See Dialog::alignment.
constraints: Option<BoxConstraints>See Dialog::constraints.
scrollable: boolDetermines whether the title and content widgets
are wrapped in a scrollable.
This configuration is used when the title and
content are expected to overflow. Both title and
content are wrapped in a scroll view, allowing all overflowed
content to be visible while still showing the button bar.
Implementations§
Source§impl AlertDialog
impl AlertDialog
Sourcepub fn new() -> AlertDialog
pub fn new() -> AlertDialog
Creates an alert dialog.
Typically used in conjunction with ShowDialog.
The title_padding and
content_padding default to null, which implies a default
that depends on the values of the other properties. See the documentation of
title_padding and content_padding
on how the padding is implemented.
Sourcepub fn adaptive() -> AlertDialog
pub fn adaptive() -> AlertDialog
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,
scroll_controller, action_scroll_controller, inset_animation_duration, and
inset_animation_curve. If a material AlertDialog is created,
scroll_controller, action_scroll_controller, inset_animation_duration, and
inset_animation_curve are ignored.
The target platform is based on the current Theme: ThemeData::platform.
Sourcepub fn key(self, key: KeyRef) -> AlertDialog
pub fn key(self, key: KeyRef) -> AlertDialog
Dart AlertDialog(key:).
Sourcepub fn icon<K>(self, icon: impl IntoWidget<K>) -> AlertDialog
pub fn icon<K>(self, icon: impl IntoWidget<K>) -> AlertDialog
Dart AlertDialog(icon:).
Sourcepub fn icon_padding(
self,
icon_padding: impl Into<EdgeInsetsGeometry>,
) -> AlertDialog
pub fn icon_padding( self, icon_padding: impl Into<EdgeInsetsGeometry>, ) -> AlertDialog
Dart AlertDialog(iconPadding:).
Sourcepub fn icon_color(self, icon_color: Color) -> AlertDialog
pub fn icon_color(self, icon_color: Color) -> AlertDialog
Dart AlertDialog(iconColor:).
Sourcepub fn title<K>(self, title: impl IntoWidget<K>) -> AlertDialog
pub fn title<K>(self, title: impl IntoWidget<K>) -> AlertDialog
Dart AlertDialog(title:).
Sourcepub fn title_padding(
self,
title_padding: impl Into<EdgeInsetsGeometry>,
) -> AlertDialog
pub fn title_padding( self, title_padding: impl Into<EdgeInsetsGeometry>, ) -> AlertDialog
Dart AlertDialog(titlePadding:).
Sourcepub fn title_text_style(self, title_text_style: TextStyle) -> AlertDialog
pub fn title_text_style(self, title_text_style: TextStyle) -> AlertDialog
Dart AlertDialog(titleTextStyle:).
Sourcepub fn content<K>(self, content: impl IntoWidget<K>) -> AlertDialog
pub fn content<K>(self, content: impl IntoWidget<K>) -> AlertDialog
Dart AlertDialog(content:).
Sourcepub fn content_padding(
self,
content_padding: impl Into<EdgeInsetsGeometry>,
) -> AlertDialog
pub fn content_padding( self, content_padding: impl Into<EdgeInsetsGeometry>, ) -> AlertDialog
Dart AlertDialog(contentPadding:).
Sourcepub fn content_text_style(self, content_text_style: TextStyle) -> AlertDialog
pub fn content_text_style(self, content_text_style: TextStyle) -> AlertDialog
Dart AlertDialog(contentTextStyle:).
Sourcepub fn actions(
self,
actions: impl IntoIterator<Item = WidgetRef>,
) -> AlertDialog
pub fn actions( self, actions: impl IntoIterator<Item = WidgetRef>, ) -> AlertDialog
Dart AlertDialog(actions:).
Sourcepub fn actions_padding(
self,
actions_padding: impl Into<EdgeInsetsGeometry>,
) -> AlertDialog
pub fn actions_padding( self, actions_padding: impl Into<EdgeInsetsGeometry>, ) -> AlertDialog
Dart AlertDialog(actionsPadding:).
Sourcepub fn actions_alignment(
self,
actions_alignment: MainAxisAlignment,
) -> AlertDialog
pub fn actions_alignment( self, actions_alignment: MainAxisAlignment, ) -> AlertDialog
Dart AlertDialog(actionsAlignment:).
Sourcepub fn actions_overflow_alignment(
self,
actions_overflow_alignment: OverflowBarAlignment,
) -> AlertDialog
pub fn actions_overflow_alignment( self, actions_overflow_alignment: OverflowBarAlignment, ) -> AlertDialog
Dart AlertDialog(actionsOverflowAlignment:).
Sourcepub fn actions_overflow_direction(
self,
actions_overflow_direction: VerticalDirection,
) -> AlertDialog
pub fn actions_overflow_direction( self, actions_overflow_direction: VerticalDirection, ) -> AlertDialog
Dart AlertDialog(actionsOverflowDirection:).
Dart AlertDialog(actionsOverflowButtonSpacing:).
Dart AlertDialog(buttonPadding:).
Sourcepub fn background_color(self, background_color: Color) -> AlertDialog
pub fn background_color(self, background_color: Color) -> AlertDialog
Dart AlertDialog(backgroundColor:).
Sourcepub fn elevation(self, elevation: f64) -> AlertDialog
pub fn elevation(self, elevation: f64) -> AlertDialog
Dart AlertDialog(elevation:).
Sourcepub fn shadow_color(self, shadow_color: Color) -> AlertDialog
pub fn shadow_color(self, shadow_color: Color) -> AlertDialog
Dart AlertDialog(shadowColor:).
Sourcepub fn surface_tint_color(self, surface_tint_color: Color) -> AlertDialog
pub fn surface_tint_color(self, surface_tint_color: Color) -> AlertDialog
Dart AlertDialog(surfaceTintColor:).
Sourcepub fn semantic_label(self, semantic_label: impl Into<String>) -> AlertDialog
pub fn semantic_label(self, semantic_label: impl Into<String>) -> AlertDialog
Dart AlertDialog(semanticLabel:).
Sourcepub fn inset_padding(self, inset_padding: EdgeInsets) -> AlertDialog
pub fn inset_padding(self, inset_padding: EdgeInsets) -> AlertDialog
Dart AlertDialog(insetPadding:).
Sourcepub fn clip_behavior(self, clip_behavior: Clip) -> AlertDialog
pub fn clip_behavior(self, clip_behavior: Clip) -> AlertDialog
Dart AlertDialog(clipBehavior:).
Sourcepub fn shape(self, shape: impl Into<ShapeBorderRef>) -> AlertDialog
pub fn shape(self, shape: impl Into<ShapeBorderRef>) -> AlertDialog
Dart AlertDialog(shape:).
Sourcepub fn alignment(self, alignment: AlignmentGeometry) -> AlertDialog
pub fn alignment(self, alignment: AlignmentGeometry) -> AlertDialog
Dart AlertDialog(alignment:).
Sourcepub fn constraints(self, constraints: BoxConstraints) -> AlertDialog
pub fn constraints(self, constraints: BoxConstraints) -> AlertDialog
Dart AlertDialog(constraints:).
Sourcepub fn scrollable(self, scrollable: bool) -> AlertDialog
pub fn scrollable(self, scrollable: bool) -> AlertDialog
Dart AlertDialog(scrollable:).
Sourcepub fn scroll_controller(
self,
scroll_controller: ScrollControllerRef,
) -> AlertDialog
pub fn scroll_controller( self, scroll_controller: ScrollControllerRef, ) -> AlertDialog
Dart AlertDialog.adaptive(scrollController:); a dialog made by
new ignores it.
Sourcepub fn action_scroll_controller(
self,
action_scroll_controller: ScrollControllerRef,
) -> AlertDialog
pub fn action_scroll_controller( self, action_scroll_controller: ScrollControllerRef, ) -> AlertDialog
Dart AlertDialog.adaptive(actionScrollController:); a dialog made by
new ignores it.
Sourcepub fn inset_animation_duration(
self,
inset_animation_duration: Duration,
) -> AlertDialog
pub fn inset_animation_duration( self, inset_animation_duration: Duration, ) -> AlertDialog
Dart AlertDialog.adaptive(insetAnimationDuration:); a dialog made by
new ignores it.
Sourcepub fn inset_animation_curve(
self,
inset_animation_curve: Rc<dyn Curve>,
) -> AlertDialog
pub fn inset_animation_curve( self, inset_animation_curve: Rc<dyn Curve>, ) -> AlertDialog
Dart AlertDialog.adaptive(insetAnimationCurve:); a dialog made by
new ignores it.
Trait Implementations§
Source§impl Debug for AlertDialog
impl Debug for AlertDialog
Source§impl Default for AlertDialog
impl Default for AlertDialog
Source§fn default() -> AlertDialog
fn default() -> AlertDialog
Source§impl StatelessWidget for AlertDialog
impl StatelessWidget for AlertDialog
Source§fn build(&self, app: &mut App, context: BuildContext) -> WidgetRef
fn build(&self, app: &mut App, context: BuildContext) -> WidgetRef
Source§fn debug_fill_properties(
&self,
_app: &App,
properties: &mut DiagnosticPropertiesBuilder,
)
fn debug_fill_properties( &self, _app: &App, properties: &mut DiagnosticPropertiesBuilder, )
debugFillProperties: the properties a dump shows for this widget, in Dart’s
order. Dart’s Widget base only sets the dense tree style, which the framework does.Source§fn debug_check_constructor(&self)
fn debug_check_constructor(&self)
Source§fn as_preferred_size_widget(
&self,
) -> Option<&(dyn PreferredSizeWidget + 'static)>
fn as_preferred_size_widget( &self, ) -> Option<&(dyn PreferredSizeWidget + 'static)>
this is PreferredSizeWidget: a widget that implements PreferredSizeWidget
answers with itself, which is what a parent asking an erased child for its preferred
size reads.Auto Trait Implementations§
impl !RefUnwindSafe for AlertDialog
impl !Send for AlertDialog
impl !Sync for AlertDialog
impl !UnwindSafe for AlertDialog
impl Forget for AlertDialog
impl Freeze for AlertDialogwhere
*const RcInner<dyn Key> is !null: Freeze,
PhantomData<RcInner<dyn Key>>: Freeze,
*const RcInner<dyn Widget> is !null: Freeze,
PhantomData<RcInner<dyn Widget>>: Freeze,
&'static dyn ColorExtension: Freeze,
*const RcInner<dyn ColorExtension> is !null: Freeze,
PhantomData<RcInner<dyn ColorExtension>>: Freeze,
*const u8 is !null: Freeze,
PhantomData<u8>: Freeze,
PhantomData<String>: Freeze,
*const RcInner<Paint> is !null: Freeze,
PhantomData<RcInner<Paint>>: Freeze,
PhantomData<Shadow>: Freeze,
PhantomData<FontFeature>: Freeze,
PhantomData<FontVariation>: Freeze,
PhantomData<Rc<dyn Widget>>: Freeze,
*const RcInner<dyn ShapeBorder> is !null: Freeze,
PhantomData<RcInner<dyn ShapeBorder>>: Freeze,
NonZero<u32>: Freeze,
&'static ScrollControllerVTable: Freeze,
*const RcInner<Keep> is !null: Freeze,
PhantomData<RcInner<Keep>>: Freeze,
*const RcInner<dyn Curve> is !null: Freeze,
PhantomData<RcInner<dyn Curve>>: Freeze,
impl Move for AlertDialog
impl Unpin for AlertDialog
impl UnsafeUnpin for AlertDialogwhere
*const RcInner<dyn Key> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Key>>: UnsafeUnpin,
*const RcInner<dyn Widget> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Widget>>: UnsafeUnpin,
&'static dyn ColorExtension: UnsafeUnpin,
*const RcInner<dyn ColorExtension> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn ColorExtension>>: UnsafeUnpin,
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
PhantomData<String>: UnsafeUnpin,
*const RcInner<Paint> is !null: UnsafeUnpin,
PhantomData<RcInner<Paint>>: UnsafeUnpin,
PhantomData<Shadow>: UnsafeUnpin,
PhantomData<FontFeature>: UnsafeUnpin,
PhantomData<FontVariation>: UnsafeUnpin,
PhantomData<Rc<dyn Widget>>: UnsafeUnpin,
*const RcInner<dyn ShapeBorder> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn ShapeBorder>>: UnsafeUnpin,
NonZeroU32Inner: UnsafeUnpin,
&'static ScrollControllerVTable: UnsafeUnpin,
*const RcInner<Keep> is !null: UnsafeUnpin,
PhantomData<RcInner<Keep>>: UnsafeUnpin,
*const RcInner<dyn Curve> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Curve>>: UnsafeUnpin,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<W> IntoWidget<StatelessKind> for Wwhere
W: StatelessWidget,
impl<W> IntoWidget<StatelessKind> for Wwhere
W: StatelessWidget,
Source§fn into_widget(self) -> Rc<dyn Widget>
fn into_widget(self) -> Rc<dyn Widget>
creation_location.