Skip to main content

AlertDialog

Struct AlertDialog 

Source
pub struct AlertDialog<Msg = Callback> { /* private fields */ }
Expand description

A dialog that asks something: an optional icon, an optional title, some content, and the buttons that answer it.

The paddings are the reference’s, and conditional the way the reference’s are: a title under an icon loses its top padding, a title with content below it loses its bottom padding, and a title with nothing below it keeps twenty of it (dialog.dart:824). An icon also centres the title, which is the one place the presence of one slot changes how another is aligned (dialog.dart:844).

Implementations§

Source§

impl<Msg: Clone + 'static> AlertDialog<Msg>

Source

pub fn new(open: bool) -> Self

Creates one; open says whether it is showing.

Source

pub fn on_dismiss(self, message: impl Into<Msg>) -> Self

What a click on the scrim sends. Without it the scrim is inert — the reference’s barrierDismissible: false, for a question a button has to answer.

Source

pub fn icon(self, icon: impl Widget<Msg> + 'static) -> Self

A glyph above the title, centred. Having one centres the title too.

Source

pub fn icon_color(self, color: Color) -> Self

The icon’s colour. The scheme’s secondary by default (dialog.dart:1976).

Source

pub fn title(self, title: impl Into<String>) -> Self

The heading, as text.

Source

pub fn title_widget(self, title: impl Widget<Msg> + 'static) -> Self

The heading, as a widget.

Source

pub fn title_text_style(self, style: TextStyle) -> Self

The heading’s type. headlineSmall by default.

Source

pub fn content(self, content: impl Into<String>) -> Self

What the dialog says, as text.

Source

pub fn content_widget(self, content: impl Widget<Msg> + 'static) -> Self

What the dialog says, as a widget.

Source

pub fn content_text_style(self, style: TextStyle) -> Self

The content’s type. bodyMedium by default.

Source

pub fn action(self, action: impl Widget<Msg> + 'static) -> Self

Adds a button to the row along the bottom.

Source

pub fn actions_alignment(self, alignment: ActionsAlignment) -> Self

Where the buttons sit along that row. The trailing end by default, as in the reference (MainAxisAlignment.end).

Source

pub fn actions_overflow_alignment(self, alignment: Align) -> Self

Which edge the buttons line up on once they have stacked — see OverflowBar::overflow_alignment. The trailing end by default, so a column of answers sits where the row of them was (dialog.dart:610).

Source

pub fn actions_overflow_direction(self, direction: VerticalDirection) -> Self

Which way that column runs — see OverflowBar::overflow_direction. Downwards by default, so the buttons stack in the order they were given.

Worth saying for a destructive answer: last on a line is first in a column, so a dialog that folds moves “Delete” to where the thumb was reaching for “Cancel”. VerticalDirection::Up is how an application says to keep it last.

Source

pub fn actions_overflow_button_spacing(self, spacing: f32) -> Self

The space between the buttons once they have stacked, which is not the space between them on one line (dialog.dart:613). Nothing by default, as in the reference: buttons that already pad themselves need no more.

Source

pub fn background(self, color: Color) -> Self

The surface’s colour — see Dialog::background.

Source

pub fn elevation(self, elevation: f32) -> Self

How far off the page it sits — see Dialog::elevation.

Source

pub fn shadow_color(self, color: Color) -> Self

The shadow’s colour — see Dialog::shadow_color.

Source

pub fn surface_tint(self, color: Color) -> Self

The tint for its elevation — see Dialog::surface_tint.

Source

pub fn shape(self, shape: ShapeBorder) -> Self

What shape it is — see Dialog::shape.

Source

pub fn inset_padding(self, padding: Insets) -> Self

How far off the window’s edges — see Dialog::inset_padding.

Source

pub fn min_width(self, width: f32) -> Self

The narrowest it gets — see Dialog::min_width.

Source

pub fn max_width(self, width: f32) -> Self

The widest it gets — see Dialog::max_width.

Source

pub fn body(self, body: impl Widget<Msg> + 'static) -> Dialog<Msg>

Sets the screen behind it and finalises the dialog.

The column is composed by a ThemeBuilder: the title’s type comes from the theme and its alignment from whether there is an icon, so what the column contains cannot be decided before the theme is known.

Auto Trait Implementations§

§

impl<Msg = Callback> !RefUnwindSafe for AlertDialog<Msg>

§

impl<Msg = Callback> !Send for AlertDialog<Msg>

§

impl<Msg = Callback> !Sync for AlertDialog<Msg>

§

impl<Msg = Callback> !UnwindSafe for AlertDialog<Msg>

§

impl<Msg> Freeze for AlertDialog<Msg>
where Dialog<Msg>: Freeze, Option<Box<dyn Widget<Msg>>>: Freeze, Vec<Box<dyn Widget<Msg>>>: Freeze,

§

impl<Msg> Unpin for AlertDialog<Msg>
where Dialog<Msg>: Unpin, Option<Box<dyn Widget<Msg>>>: Unpin, Vec<Box<dyn Widget<Msg>>>: Unpin,

§

impl<Msg> UnsafeUnpin for AlertDialog<Msg>
where Dialog<Msg>: UnsafeUnpin, Option<Box<dyn Widget<Msg>>>: UnsafeUnpin, Vec<Box<dyn Widget<Msg>>>: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<Msg> IntoMsg<Msg> for Msg

Source§

fn defer(work: impl Fn() -> Msg + 'static) -> Msg

The message that stands for work’s result.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.