pub struct ShowBottomSheet { /* private fields */ }Expand description
Shows a Material Design bottom sheet in the nearest Scaffold ancestor. To
show a persistent bottom sheet, use the Scaffold::bottom_sheet.
Returns a controller that can be used to close and otherwise manipulate the bottom sheet.
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
persistent bottom sheets (see the documentation for these on BottomSheet
for more details).
The enable_drag parameter specifies whether the bottom sheet can be
dragged up and down and dismissed by swiping downwards.
The sheet_animation_style parameter is used to override the bottom sheet
animation duration and reverse animation duration.
If AnimationStyle.duration is provided, it will be used to override
the bottom sheet animation duration in the underlying
BottomSheet::create_animation_controller.
If AnimationStyle.reverseDuration is provided, it will be used to
override the bottom sheet reverse animation duration in the underlying
BottomSheet::create_animation_controller.
To disable the bottom sheet animation, use AnimationStyle.noAnimation.
To rebuild the bottom sheet (e.g. if it is stateful), call
PersistentBottomSheetController::set_state on the controller returned by
this method.
The new bottom sheet becomes a LocalHistoryEntry for the enclosing
ModalRoute and a back button is added to the app bar of the Scaffold
that closes the bottom sheet.
To create a persistent bottom sheet that is not a LocalHistoryEntry and
does not add a back button to the enclosing Scaffold’s app bar, use the
Scaffold::bottom_sheet constructor parameter.
A closely related widget is a modal bottom sheet, which is an alternative
to a menu or a dialog and prevents the user from interacting with the rest
of the app. Modal bottom sheets can be created and displayed with the
ShowModalBottomSheet function.
The context argument is used to look up the Scaffold 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.
See also:
BottomSheet, which becomes the parent of the widget returned by thebuilder.ShowModalBottomSheet, which can be used to display a modal bottom sheet.Scaffold::of, for information about how to obtain theBuildContext.- 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 bottom sheet animation duration and reverse animation duration.
Implementations§
Source§impl ShowBottomSheet
impl ShowBottomSheet
Sourcepub fn new(builder: WidgetBuilder) -> ShowBottomSheet
pub fn new(builder: WidgetBuilder) -> ShowBottomSheet
Creates a builder for a persistent bottom sheet; Dart’s showBottomSheet required
argument is the builder, and every other argument is a setter.
Sourcepub fn background_color(self, background_color: Color) -> ShowBottomSheet
pub fn background_color(self, background_color: Color) -> ShowBottomSheet
The background color of the sheet.
Sourcepub fn elevation(self, elevation: f64) -> ShowBottomSheet
pub fn elevation(self, elevation: f64) -> ShowBottomSheet
The z-coordinate of the sheet.
Sourcepub fn shape(self, shape: impl Into<ShapeBorderRef>) -> ShowBottomSheet
pub fn shape(self, shape: impl Into<ShapeBorderRef>) -> ShowBottomSheet
The shape of the sheet’s material.
Sourcepub fn clip_behavior(self, clip_behavior: Clip) -> ShowBottomSheet
pub fn clip_behavior(self, clip_behavior: Clip) -> ShowBottomSheet
The clip behavior of the sheet.
Sourcepub fn constraints(self, constraints: BoxConstraints) -> ShowBottomSheet
pub fn constraints(self, constraints: BoxConstraints) -> ShowBottomSheet
The size constraints on the sheet.
Sourcepub fn enable_drag(self, enable_drag: bool) -> ShowBottomSheet
pub fn enable_drag(self, enable_drag: bool) -> ShowBottomSheet
Whether the sheet can be dragged up and down.
Sourcepub fn show_drag_handle(self, show_drag_handle: bool) -> ShowBottomSheet
pub fn show_drag_handle(self, show_drag_handle: bool) -> ShowBottomSheet
Whether the sheet shows a drag handle.
Sourcepub fn transition_animation_controller(
self,
transition_animation_controller: Ref<AnimationController>,
) -> ShowBottomSheet
pub fn transition_animation_controller( self, transition_animation_controller: Ref<AnimationController>, ) -> ShowBottomSheet
An animation controller the sheet uses instead of creating one.
Sourcepub fn sheet_animation_style(
self,
sheet_animation_style: AnimationStyle,
) -> ShowBottomSheet
pub fn sheet_animation_style( self, sheet_animation_style: AnimationStyle, ) -> ShowBottomSheet
An animation style that overrides the sheet’s animation durations.
Sourcepub fn show(
self,
app: &mut App,
context: BuildContext,
) -> Rc<PersistentBottomSheetController>
pub fn show( self, app: &mut App, context: BuildContext, ) -> Rc<PersistentBottomSheetController>
Shows the sheet and returns its controller.