pub struct ShowModalBottomSheet { /* private fields */ }Expand description
Shows a modal Material Design bottom sheet.
A modal bottom sheet is an alternative to a menu or a dialog and prevents the user from interacting with the rest of the app.
A closely related widget is a persistent bottom sheet, which shows
information that supplements the primary content of the app without
preventing the user from interacting with the app. Persistent bottom sheets
can be created and displayed with the ShowBottomSheet builder or the
ScaffoldState::show_bottom_sheet method.
The is_scroll_controlled parameter specifies whether this is a route for
a bottom sheet that will utilize DraggableScrollableSheet. Consider
setting this parameter to true if this bottom sheet has
a scrollable child, such as a ListView or a GridView,
to have the bottom sheet be draggable.
The is_dismissible parameter specifies whether the bottom sheet will be
dismissed when user taps on the scrim.
The enable_drag parameter specifies whether the bottom sheet can be
dragged up and down and dismissed by swiping downwards.
The use_safe_area parameter specifies whether the sheet will avoid system
intrusions on the top, left, and right. If false, no SafeArea is added;
and MediaQuery::remove_padding is applied to the top,
so that system intrusions at the top will not be avoided by a SafeArea
inside the bottom sheet either.
Defaults to false.
The optional background_color, elevation, shape, clip_behavior,
constraints and transition_animation_controller
parameters can be passed in to customize the appearance and behavior of
modal bottom sheets (see the documentation for these on BottomSheet
for more details).
The transition_animation_controller controls the bottom sheet’s entrance and
exit animations. It’s up to the owner of the controller to call
AnimationController::dispose when the controller is no longer needed.
The optional route_settings parameter sets the RouteSettings of the modal bottom
sheet sheet. This is particularly useful in the case that a user wants to observe
PopupRoutes within a NavigatorObserver.
The context argument is used to look up the Navigator and Theme for
the bottom sheet. It is only used when the method is called. Its
corresponding widget can be safely removed from the tree before the bottom
sheet is closed.
The use_root_navigator parameter ensures that the root navigator is used to
display the BottomSheet when set to true. This is useful in the case
that a modal BottomSheet needs to be displayed above all other content
but the caller is inside another Navigator.
Returns a Future that resolves to the value (if any) that was passed to
Navigator::pop when the modal bottom sheet was closed.
The ‘barrier_label’ parameter can be used to set a custom barrier label.
Will default to MaterialLocalizations::modal_barrier_dismiss_label of context
if not set.
The sheet_animation_style parameter is used to override the modal bottom sheet
animation duration and reverse animation duration.
The request_focus parameter is used to specify whether the bottom sheet should
request focus when shown.
If AnimationStyle.duration is provided, it will be used to override
the modal bottom sheet animation duration in the underlying
BottomSheet::create_animation_controller.
If AnimationStyle.reverseDuration is provided, it will be used to
override the modal bottom sheet reverse animation duration in the
underlying BottomSheet::create_animation_controller.
To disable the bottom sheet animation, use AnimationStyle.noAnimation.
See also:
BottomSheet, which becomes the parent of the widget returned by the function passed as thebuilderargument toShowModalBottomSheet.- [
show_bottom_sheet] andScaffoldState::show_bottom_sheet, for showing non-modal bottom sheets. DraggableScrollableSheet, creates a bottom sheet that grows and then becomes scrollable once it reaches its maximum size.- The Material 2 spec at https://m2.material.io/components/sheets-bottom.
- The Material 3 spec at https://m3.material.io/components/bottom-sheets/overview.
AnimationStyle, which is used to override the modal bottom sheet animation duration and reverse animation duration.
Implementations§
Source§impl ShowModalBottomSheet
impl ShowModalBottomSheet
Sourcepub fn new(builder: WidgetBuilder) -> ShowModalBottomSheet
pub fn new(builder: WidgetBuilder) -> ShowModalBottomSheet
Creates a builder for a modal bottom sheet; Dart’s showModalBottomSheet required
argument is the builder, and every other argument is a setter.
Sourcepub fn background_color(self, background_color: Color) -> ShowModalBottomSheet
pub fn background_color(self, background_color: Color) -> ShowModalBottomSheet
The background color of the sheet.
Sourcepub fn barrier_label(
self,
barrier_label: impl Into<String>,
) -> ShowModalBottomSheet
pub fn barrier_label( self, barrier_label: impl Into<String>, ) -> ShowModalBottomSheet
The semantic label of the sheet’s modal barrier.
Sourcepub fn elevation(self, elevation: f64) -> ShowModalBottomSheet
pub fn elevation(self, elevation: f64) -> ShowModalBottomSheet
The z-coordinate of the sheet.
Sourcepub fn shape(self, shape: impl Into<ShapeBorderRef>) -> ShowModalBottomSheet
pub fn shape(self, shape: impl Into<ShapeBorderRef>) -> ShowModalBottomSheet
The shape of the sheet’s material.
Sourcepub fn clip_behavior(self, clip_behavior: Clip) -> ShowModalBottomSheet
pub fn clip_behavior(self, clip_behavior: Clip) -> ShowModalBottomSheet
The clip behavior of the sheet.
Sourcepub fn constraints(self, constraints: BoxConstraints) -> ShowModalBottomSheet
pub fn constraints(self, constraints: BoxConstraints) -> ShowModalBottomSheet
The size constraints on the sheet.
Sourcepub fn barrier_color(self, barrier_color: Color) -> ShowModalBottomSheet
pub fn barrier_color(self, barrier_color: Color) -> ShowModalBottomSheet
The color of the modal barrier below the sheet.
Sourcepub fn is_scroll_controlled(
self,
is_scroll_controlled: bool,
) -> ShowModalBottomSheet
pub fn is_scroll_controlled( self, is_scroll_controlled: bool, ) -> ShowModalBottomSheet
Whether the sheet may take the full height when a scroll view is inside it. Defaults to
false.
Sourcepub fn scroll_control_disabled_max_height_ratio(
self,
scroll_control_disabled_max_height_ratio: f64,
) -> ShowModalBottomSheet
pub fn scroll_control_disabled_max_height_ratio( self, scroll_control_disabled_max_height_ratio: f64, ) -> ShowModalBottomSheet
The maximum height of a non-scroll-controlled sheet, as a ratio of the available height.
Whether to push the sheet to the root navigator. Defaults to false.
Sourcepub fn is_dismissible(self, is_dismissible: bool) -> ShowModalBottomSheet
pub fn is_dismissible(self, is_dismissible: bool) -> ShowModalBottomSheet
Whether tapping the barrier dismisses the sheet. Defaults to true.
Sourcepub fn enable_drag(self, enable_drag: bool) -> ShowModalBottomSheet
pub fn enable_drag(self, enable_drag: bool) -> ShowModalBottomSheet
Whether the sheet can be dragged up and down. Defaults to true.
Sourcepub fn show_drag_handle(self, show_drag_handle: bool) -> ShowModalBottomSheet
pub fn show_drag_handle(self, show_drag_handle: bool) -> ShowModalBottomSheet
Whether the sheet shows a drag handle.
Sourcepub fn use_safe_area(self, use_safe_area: bool) -> ShowModalBottomSheet
pub fn use_safe_area(self, use_safe_area: bool) -> ShowModalBottomSheet
Whether the sheet avoids the operating system’s safe areas. Defaults to false.
Sourcepub fn route_settings(
self,
route_settings: RouteSettingsRef,
) -> ShowModalBottomSheet
pub fn route_settings( self, route_settings: RouteSettingsRef, ) -> ShowModalBottomSheet
The route settings passed to the sheet’s route.
Sourcepub fn transition_animation_controller(
self,
transition_animation_controller: Ref<AnimationController>,
) -> ShowModalBottomSheet
pub fn transition_animation_controller( self, transition_animation_controller: Ref<AnimationController>, ) -> ShowModalBottomSheet
An animation controller the sheet uses instead of creating one.
Sourcepub fn sheet_animation_style(
self,
sheet_animation_style: AnimationStyle,
) -> ShowModalBottomSheet
pub fn sheet_animation_style( self, sheet_animation_style: AnimationStyle, ) -> ShowModalBottomSheet
An animation style that overrides the sheet’s animation durations.
Sourcepub fn request_focus(self, request_focus: bool) -> ShowModalBottomSheet
pub fn request_focus(self, request_focus: bool) -> ShowModalBottomSheet
Whether the sheet’s route requests focus when it is pushed.
Sourcepub fn show(
self,
app: &mut App,
context: BuildContext,
) -> CompleterFuture<RouteResult> ⓘ
pub fn show( self, app: &mut App, context: BuildContext, ) -> CompleterFuture<RouteResult> ⓘ
Shows the sheet and returns a future that resolves to the value passed to
Navigator::pop when it closes.