Skip to main content

Dialog

Struct Dialog 

Source
pub struct Dialog {
Show 14 fields pub key: Option<KeyRef>, pub background_color: Option<Color>, pub elevation: Option<f64>, pub shadow_color: Option<Color>, pub surface_tint_color: Option<Color>, pub inset_animation_duration: Duration, pub inset_animation_curve: Rc<dyn Curve>, pub inset_padding: Option<EdgeInsets>, pub clip_behavior: Option<Clip>, pub shape: Option<ShapeBorderRef>, pub alignment: Option<AlignmentGeometry>, pub child: Option<WidgetRef>, pub semantics_role: SemanticsRole, pub constraints: Option<BoxConstraints>, /* private fields */
}
Expand description

A Material Design dialog.

This dialog widget does not have any opinion about the contents of the dialog. Rather than using this widget directly, consider using AlertDialog or SimpleDialog, which implement specific kinds of Material Design dialogs.

§Constraints

The Material 3 guideline recommends that a dialog should have a maximal width of 560dp. For historical reasons, Flutter’s Dialog widget does not come with this constraint by default. For applications targeting large screens such as desktop or Web, it is recommended to set the constraints property.

One set of setters serves both of Dart’s constructors, Dialog::new and Dialog::fullscreen.

See also:

Fields§

§key: Option<KeyRef>§background_color: Option<Color>

The background color of the surface of this Dialog.

This sets the Material::color on this Dialog’s Material.

If null, then the DialogThemeData::background_color is used. If that is also null, defaults to ColorScheme::surface_container_high. If ThemeData::use_material3 is false, defaults to Colors::GREY with a shade of 800 in dark theme and Colors::WHITE in light theme.

If Dialog::fullscreen is used, defaults to ColorScheme::surface.

§elevation: Option<f64>

The z-coordinate of this Dialog.

Controls how far above the parent the dialog will appear. Elevation is represented by a drop shadow if shadow_color is non null, and a surface tint overlay on the background color if surface_tint_color is non null.

If null then DialogThemeData::elevation is used, and if that is null then the elevation will match the Material Design specification for Dialogs.

§shadow_color: Option<Color>

The color used to paint a drop shadow under the dialog’s Material, which reflects the dialog’s elevation.

If null and ThemeData::use_material3 is true then no drop shadow will be rendered.

If null and ThemeData::use_material3 is false then it will default to ThemeData::shadow_color.

§surface_tint_color: Option<Color>

The color used as a surface tint overlay on the dialog’s background color, which reflects the dialog’s elevation.

If ThemeData::use_material3 is false property has no effect.

defaults to Colors::TRANSPARENT.

To disable this feature, set surface_tint_color to Colors::TRANSPARENT.

§inset_animation_duration: Duration

The duration of the animation to show when the system keyboard intrudes into the space that the dialog is placed in.

Defaults to 100 milliseconds.

§inset_animation_curve: Rc<dyn Curve>

The curve to use for the animation shown when the system keyboard intrudes into the space that the dialog is placed in.

Defaults to Curves::decelerate.

§inset_padding: Option<EdgeInsets>

The amount of padding added to MediaQueryData::view_insets on the outside of the dialog. This defines the minimum space between the screen’s edges and the dialog.

Defaults to EdgeInsets.symmetric(horizontal: 40.0, vertical: 24.0).

§clip_behavior: Option<Clip>

Controls how the contents of the dialog are clipped (or not) to the given shape.

See the enum Clip for details of all possible options and their common use cases.

If null, then DialogThemeData::clip_behavior is used. If that is also null, defaults to Clip::None.

§shape: Option<ShapeBorderRef>

The shape of this dialog’s border.

Defines the dialog’s Material::shape.

The default shape is a RoundedRectangleBorder with a radius of 4.0

§alignment: Option<AlignmentGeometry>

How to align the Dialog.

If null, then DialogThemeData::alignment is used. If that is also null, the default is Alignment::CENTER.

§child: Option<WidgetRef>

The widget below this widget in the tree.

§semantics_role: SemanticsRole

The role this dialog represent in assist technologies.

Defaults to SemanticsRole::Dialog.

§constraints: Option<BoxConstraints>

Constrains the size of the dialog.

If null, then DialogThemeData::constraints is used. If that is also null, the default is const BoxConstraints(minWidth: 280.0).

Implementations§

Source§

impl Dialog

Source

pub fn new() -> Dialog

Creates a dialog.

Typically used in conjunction with ShowDialog.

Source

pub fn fullscreen() -> Dialog

Creates a fullscreen dialog.

Typically used in conjunction with ShowDialog.

The dialog’s Material covers the whole screen, including the area behind the software keyboard, while child is kept above the keyboard, so that a translucent keyboard shows the dialog’s background_color rather than what is behind the dialog.

Source

pub fn key(self, key: KeyRef) -> Dialog

Dart Dialog(key:).

Source

pub fn background_color(self, background_color: Color) -> Dialog

Dart Dialog(backgroundColor:).

Source

pub fn elevation(self, elevation: f64) -> Dialog

Dart Dialog(elevation:).

Source

pub fn shadow_color(self, shadow_color: Color) -> Dialog

Dart Dialog(shadowColor:).

Source

pub fn surface_tint_color(self, surface_tint_color: Color) -> Dialog

Dart Dialog(surfaceTintColor:).

Source

pub fn inset_animation_duration( self, inset_animation_duration: Duration, ) -> Dialog

Dart Dialog(insetAnimationDuration:).

Source

pub fn inset_animation_curve( self, inset_animation_curve: Rc<dyn Curve>, ) -> Dialog

Dart Dialog(insetAnimationCurve:).

Source

pub fn inset_padding(self, inset_padding: EdgeInsets) -> Dialog

Dart Dialog(insetPadding:).

Source

pub fn clip_behavior(self, clip_behavior: Clip) -> Dialog

Dart Dialog(clipBehavior:).

Source

pub fn shape(self, shape: impl Into<ShapeBorderRef>) -> Dialog

Dart Dialog(shape:).

Source

pub fn alignment(self, alignment: AlignmentGeometry) -> Dialog

Dart Dialog(alignment:).

Source

pub fn child<K>(self, child: impl IntoWidget<K>) -> Dialog

Dart Dialog(child:).

Source

pub fn semantics_role(self, semantics_role: SemanticsRole) -> Dialog

Dart Dialog(semanticsRole:).

Source

pub fn constraints(self, constraints: BoxConstraints) -> Dialog

Dart Dialog(constraints:).

Trait Implementations§

Source§

impl Debug for Dialog

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Dialog

Source§

fn default() -> Dialog

Returns the “default value” for a type. Read more
Source§

impl StatelessWidget for Dialog

Source§

fn key(&self) -> Option<&KeyRef>

Source§

fn build(&self, app: &mut App, context: BuildContext) -> WidgetRef

Describes the part of the user interface represented by this widget. Read more
Source§

fn debug_fill_properties( &self, _app: &App, properties: &mut DiagnosticPropertiesBuilder, )

Dart’s 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)

Dart’s constructor asserts that relate two or more arguments. Read more
Source§

fn as_preferred_size_widget( &self, ) -> Option<&(dyn PreferredSizeWidget + 'static)>

Dart’s 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 Dialog

§

impl !Send for Dialog

§

impl !Sync for Dialog

§

impl !UnwindSafe for Dialog

§

impl Forget for Dialog

§

impl Freeze for Dialog
where *const RcInner<dyn Key> is !null: Freeze, PhantomData<RcInner<dyn Key>>: Freeze, *const RcInner<dyn Curve> is !null: Freeze, PhantomData<RcInner<dyn Curve>>: Freeze, *const RcInner<dyn ShapeBorder> is !null: Freeze, PhantomData<RcInner<dyn ShapeBorder>>: Freeze, *const RcInner<dyn Widget> is !null: Freeze, PhantomData<RcInner<dyn Widget>>: Freeze,

§

impl Move for Dialog

§

impl Unpin for Dialog
where Rc<dyn Key>: Unpin, Rc<dyn Curve>: Unpin, Rc<dyn ShapeBorder>: Unpin, Rc<dyn Widget>: Unpin,

§

impl UnsafeUnpin for Dialog
where *const RcInner<dyn Key> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Key>>: UnsafeUnpin, *const RcInner<dyn Curve> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Curve>>: UnsafeUnpin, *const RcInner<dyn ShapeBorder> is !null: UnsafeUnpin, PhantomData<RcInner<dyn ShapeBorder>>: UnsafeUnpin, *const RcInner<dyn Widget> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Widget>>: 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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

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<W> IntoWidget<StatelessKind> for W
where W: StatelessWidget,

Source§

fn into_widget(self) -> Rc<dyn Widget>

The widget as a tree node, made where this is called: its creation_location.
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>