pub struct ShowDialog { /* private fields */ }Expand description
Displays a Material dialog above the current contents of the app, with Material entrance and exit animations, modal barrier color, and modal barrier behavior (dialog is dismissible with a tap on the barrier).
This function takes a builder which typically builds a Dialog widget.
Content below the dialog is dimmed with a ModalBarrier. The widget
returned by the builder does not share a context with the location that
ShowDialog is originally called from. Use a StatefulBuilder or a
custom StatefulWidget if the dialog needs to update dynamically.
The context argument is used to look up the Navigator and Theme for
the dialog. It is only used when the method is called. Its corresponding
widget can be safely removed from the tree before the dialog is closed.
The barrier_dismissible argument is used to indicate whether tapping on the
barrier will dismiss the dialog. It is true by default and can not be null.
The barrier_color argument is used to specify the color of the modal
barrier that darkens everything below the dialog. If null the barrier_color
field from DialogThemeData is used. If that is null the default color
Colors::BLACK54 is used.
The use_safe_area argument is used to indicate if the dialog should only
display in ‘safe’ areas of the screen not used by the operating system
(see SafeArea for more details). It is true by default, which means
the dialog will not overlap operating system areas. If it is set to false
the dialog will only be constrained by the screen size. It can not be null.
The use_root_navigator argument is used to determine whether to push the
dialog to the Navigator furthest from or nearest to the given context.
By default, use_root_navigator is true and the dialog route created by
this method is pushed to the root navigator. It can not be null.
The route_settings argument is passed to DialogRoute::settings.
If not null, the traversal_edge_behavior argument specifies the transfer of
focus beyond the first and the last items of the dialog route. By default,
TraversalEdgeBehavior::ClosedLoop is used, because it’s typical for dialogs
to allow users to cycle through dialog widgets without leaving the dialog.
If animation_style is provided, it will be used to override the default
animation duration and curves of the dialog.
Returns a future that resolves to the value (if any) that was passed to
Navigator::pop when the dialog was closed.
See also:
AlertDialog, for dialogs that have a row of buttons below a body.SimpleDialog, which handles the scrolling of the contents and does not show buttons below its body.Dialog, on whichSimpleDialogandAlertDialogare based.ShowCupertinoDialog, which displays an iOS-style dialog.ShowGeneralDialog, which allows for customization of the dialog popup.DialogRoute, the route this pushes.- https://material.io/design/components/dialogs.html
- https://m3.material.io/components/dialogs
Builder for ShowDialog’s arguments, in place of Dart’s named arguments.
Create one with ShowDialog::new, set what differs from Flutter’s defaults, and call
show.
Implementations§
Source§impl ShowDialog
impl ShowDialog
Sourcepub fn new(builder: WidgetBuilder) -> ShowDialog
pub fn new(builder: WidgetBuilder) -> ShowDialog
Creates a builder for a Material dialog; Dart’s showDialog required argument is the
builder, and every other argument is a setter.
Sourcepub fn barrier_dismissible(self, barrier_dismissible: bool) -> ShowDialog
pub fn barrier_dismissible(self, barrier_dismissible: bool) -> ShowDialog
Whether tapping on the barrier will dismiss the dialog. Defaults to true.
Sourcepub fn barrier_color(self, barrier_color: Color) -> ShowDialog
pub fn barrier_color(self, barrier_color: Color) -> ShowDialog
The color of the modal barrier that darkens everything below the dialog.
Sourcepub fn barrier_label(self, barrier_label: impl Into<String>) -> ShowDialog
pub fn barrier_label(self, barrier_label: impl Into<String>) -> ShowDialog
The semantic label of the dialog’s modal barrier.
Sourcepub fn use_safe_area(self, use_safe_area: bool) -> ShowDialog
pub fn use_safe_area(self, use_safe_area: bool) -> ShowDialog
Whether the dialog should only display in the safe areas of the screen. Defaults to
true.
Whether to push the dialog to the root navigator rather than the nearest one. Defaults
to true.
Sourcepub fn route_settings(self, route_settings: RouteSettingsRef) -> ShowDialog
pub fn route_settings(self, route_settings: RouteSettingsRef) -> ShowDialog
The route settings passed to DialogRoute::settings.
Sourcepub fn traversal_edge_behavior(
self,
traversal_edge_behavior: TraversalEdgeBehavior,
) -> ShowDialog
pub fn traversal_edge_behavior( self, traversal_edge_behavior: TraversalEdgeBehavior, ) -> ShowDialog
How focus transfers beyond the first and last items of the dialog route.
Sourcepub fn fullscreen_dialog(self, fullscreen_dialog: bool) -> ShowDialog
pub fn fullscreen_dialog(self, fullscreen_dialog: bool) -> ShowDialog
Whether this is a fullscreen dialog. Defaults to false.
Sourcepub fn request_focus(self, request_focus: bool) -> ShowDialog
pub fn request_focus(self, request_focus: bool) -> ShowDialog
Whether the dialog’s route requests focus when it is pushed.
Sourcepub fn animation_style(self, animation_style: AnimationStyle) -> ShowDialog
pub fn animation_style(self, animation_style: AnimationStyle) -> ShowDialog
An animation style that overrides the default animation duration and curves.
Sourcepub fn show(
self,
app: &mut App,
context: BuildContext,
) -> CompleterFuture<RouteResult> ⓘ
pub fn show( self, app: &mut App, context: BuildContext, ) -> CompleterFuture<RouteResult> ⓘ
Displays the dialog and returns a future that resolves to the value passed to
Navigator::pop when it closes.