Skip to main content

ShowModalBottomSheet

Struct ShowModalBottomSheet 

Source
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:

Implementations§

Source§

impl ShowModalBottomSheet

Source

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.

Source

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

The background color of the sheet.

Source

pub fn barrier_label( self, barrier_label: impl Into<String>, ) -> ShowModalBottomSheet

The semantic label of the sheet’s modal barrier.

Source

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

The z-coordinate of the sheet.

Source

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

The shape of the sheet’s material.

Source

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

The clip behavior of the sheet.

Source

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

The size constraints on the sheet.

Source

pub fn barrier_color(self, barrier_color: Color) -> ShowModalBottomSheet

The color of the modal barrier below the sheet.

Source

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.

Source

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.

Source

pub fn use_root_navigator( self, use_root_navigator: bool, ) -> ShowModalBottomSheet

Whether to push the sheet to the root navigator. Defaults to false.

Source

pub fn is_dismissible(self, is_dismissible: bool) -> ShowModalBottomSheet

Whether tapping the barrier dismisses the sheet. Defaults to true.

Source

pub fn enable_drag(self, enable_drag: bool) -> ShowModalBottomSheet

Whether the sheet can be dragged up and down. Defaults to true.

Source

pub fn show_drag_handle(self, show_drag_handle: bool) -> ShowModalBottomSheet

Whether the sheet shows a drag handle.

Source

pub fn use_safe_area(self, use_safe_area: bool) -> ShowModalBottomSheet

Whether the sheet avoids the operating system’s safe areas. Defaults to false.

Source

pub fn route_settings( self, route_settings: RouteSettingsRef, ) -> ShowModalBottomSheet

The route settings passed to the sheet’s route.

Source

pub fn transition_animation_controller( self, transition_animation_controller: Ref<AnimationController>, ) -> ShowModalBottomSheet

An animation controller the sheet uses instead of creating one.

Source

pub fn sheet_animation_style( self, sheet_animation_style: AnimationStyle, ) -> ShowModalBottomSheet

An animation style that overrides the sheet’s animation durations.

Source

pub fn request_focus(self, request_focus: bool) -> ShowModalBottomSheet

Whether the sheet’s route requests focus when it is pushed.

Source

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.

Auto Trait Implementations§

§

impl !RefUnwindSafe for ShowModalBottomSheet

§

impl !Send for ShowModalBottomSheet

§

impl !Sync for ShowModalBottomSheet

§

impl !UnwindSafe for ShowModalBottomSheet

§

impl Forget for ShowModalBottomSheet

§

impl Freeze for ShowModalBottomSheet
where *const RcInner<dyn Fn(&mut App, AnyElement) -> Rc<dyn Widget>> is !null: Freeze, PhantomData<RcInner<dyn Fn(&mut App, AnyElement) -> Rc<dyn Widget>>>: Freeze, *const u8 is !null: Freeze, PhantomData<u8>: Freeze, *const RcInner<dyn ShapeBorder> is !null: Freeze, PhantomData<RcInner<dyn ShapeBorder>>: Freeze, *const RcInner<dyn Any> is !null: Freeze, PhantomData<RcInner<dyn Any>>: Freeze, *const RcInner<dyn Page> is !null: Freeze, PhantomData<RcInner<dyn Page>>: Freeze, NonZero<u32>: Freeze, PhantomData<fn() -> AnimationController>: Freeze, *const RcInner<Keep> is !null: Freeze, PhantomData<RcInner<Keep>>: Freeze, *const RcInner<dyn Curve> is !null: Freeze, PhantomData<RcInner<dyn Curve>>: Freeze,

§

impl Move for ShowModalBottomSheet

§

impl Unpin for ShowModalBottomSheet
where Rc<dyn Fn(&mut App, AnyElement) -> Rc<dyn Widget>>: Unpin, *const u8 is !null: Unpin, Rc<dyn ShapeBorder>: Unpin, Rc<dyn Any>: Unpin, Rc<dyn Page>: Unpin, NonZero<u32>: Unpin, Rc<Keep>: Unpin, Rc<dyn Curve>: Unpin,

§

impl UnsafeUnpin for ShowModalBottomSheet
where *const RcInner<dyn Fn(&mut App, AnyElement) -> Rc<dyn Widget>> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Fn(&mut App, AnyElement) -> Rc<dyn Widget>>>: UnsafeUnpin, *const u8 is !null: UnsafeUnpin, PhantomData<u8>: UnsafeUnpin, *const RcInner<dyn ShapeBorder> is !null: UnsafeUnpin, PhantomData<RcInner<dyn ShapeBorder>>: UnsafeUnpin, *const RcInner<dyn Any> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Any>>: UnsafeUnpin, *const RcInner<dyn Page> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Page>>: UnsafeUnpin, NonZeroU32Inner: UnsafeUnpin, PhantomData<fn() -> AnimationController>: UnsafeUnpin, *const RcInner<Keep> is !null: UnsafeUnpin, PhantomData<RcInner<Keep>>: UnsafeUnpin, *const RcInner<dyn Curve> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Curve>>: 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<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>