Skip to main content

BottomSheet

Struct BottomSheet 

Source
pub struct BottomSheet {
Show 16 fields pub key: Option<KeyRef>, pub animation_controller: Option<Ref<AnimationController>>, pub on_closing: VoidCallback, pub builder: WidgetBuilder, pub enable_drag: bool, pub show_drag_handle: Option<bool>, pub drag_handle_color: Option<AnyColor>, pub drag_handle_size: Option<Size>, pub on_drag_start: Option<BottomSheetDragStartHandler>, pub on_drag_end: Option<BottomSheetDragEndHandler>, pub background_color: Option<Color>, pub shadow_color: Option<Color>, pub elevation: Option<f64>, pub shape: Option<ShapeBorderRef>, pub clip_behavior: Option<Clip>, pub constraints: Option<BoxConstraints>,
}
Expand description

A Material Design bottom sheet.

There are two kinds of bottom sheets in Material Design:

  • Persistent. A persistent bottom sheet shows information that supplements the primary content of the app. A persistent bottom sheet remains visible even when the user interacts with other parts of the app. Persistent bottom sheets can be created and displayed with the ScaffoldState::show_bottom_sheet function or by specifying the Scaffold::bottom_sheet constructor parameter.

  • Modal. 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. Modal bottom sheets can be created and displayed with the ShowModalBottomSheet function.

The BottomSheet widget itself is rarely used directly. Instead, prefer to create a persistent bottom sheet with ScaffoldState::show_bottom_sheet or Scaffold::bottom_sheet, and a modal bottom sheet with ShowModalBottomSheet.

See also:

Fields§

§key: Option<KeyRef>§animation_controller: Option<Ref<AnimationController>>

The animation controller that controls the bottom sheet’s entrance and exit animations.

The BottomSheet widget will manipulate the position of this animation, it is not just a passive observer.

§on_closing: VoidCallback

Called when the bottom sheet begins to close.

A bottom sheet might be prevented from closing (e.g., by user interaction) even after this callback is called. For this reason, this callback might be call multiple times for a given bottom sheet.

§builder: WidgetBuilder

A builder for the contents of the sheet.

The bottom sheet will wrap the widget produced by this builder in a Material widget.

§enable_drag: bool

If true, the bottom sheet can be dragged up and down and dismissed by swiping downwards.

If show_drag_handle is true, this only applies to the content below the drag handle, because the drag handle is always draggable.

Default is true.

If this is true, the animation_controller must not be null. Use BottomSheet::create_animation_controller to create one, or provide another AnimationController.

§show_drag_handle: Option<bool>

Specifies whether a drag handle is shown.

The drag handle appears at the top of the bottom sheet. The default color is ColorScheme.onSurfaceVariant with an opacity of 0.4 and can be customized using drag_handle_color. The default size is Size(32,4) and can be customized with drag_handle_size.

If null, then the value of BottomSheetThemeData::show_drag_handle is used. If that is also null, defaults to false.

If this is true, the animation_controller must not be null. Use BottomSheet::create_animation_controller to create one, or provide another AnimationController.

§drag_handle_color: Option<AnyColor>

The bottom sheet drag handle’s color.

Defaults to BottomSheetThemeData::drag_handle_color. If that is also null, defaults to ColorScheme.onSurfaceVariant.

§drag_handle_size: Option<Size>

Defaults to BottomSheetThemeData::drag_handle_size. If that is also null, defaults to Size(32, 4).

§on_drag_start: Option<BottomSheetDragStartHandler>

Called when the user begins dragging the bottom sheet vertically, if enable_drag is true.

Would typically be used to change the bottom sheet animation curve so that it tracks the user’s finger accurately.

§on_drag_end: Option<BottomSheetDragEndHandler>

Called when the user stops dragging the bottom sheet, if enable_drag is true.

Would typically be used to reset the bottom sheet animation curve, so that it animates non-linearly. Called before on_closing if the bottom sheet is closing.

§background_color: Option<Color>

The bottom sheet’s background color.

Defines the bottom sheet’s Material.color.

Defaults to null and falls back to Material’s default.

§shadow_color: Option<Color>

The color of the shadow below the sheet.

If this property is null, then BottomSheetThemeData::shadow_color of ThemeData.bottomSheetTheme is used. If that is also null, the default value is transparent.

See also:

  • elevation, which defines the size of the shadow below the sheet.
  • shape, which defines the shape of the sheet and its shadow.
§elevation: Option<f64>

The z-coordinate at which to place this material relative to its parent.

This controls the size of the shadow below the material.

Defaults to 0. The value is non-negative.

§shape: Option<ShapeBorderRef>

The shape of the bottom sheet.

Defines the bottom sheet’s Material.shape.

Defaults to null and falls back to Material’s default.

§clip_behavior: Option<Clip>

The content will be clipped (or not) according to this option.

Defines the bottom sheet’s Material.clipBehavior.

Use this property to enable clipping of content when the bottom sheet has a custom shape and the content can extend past this shape. For example, a bottom sheet with rounded corners and an edge-to-edge Image at the top.

If this property is null then BottomSheetThemeData::clip_behavior of ThemeData.bottomSheetTheme is used. If that’s null then the behavior will be Clip::None.

§constraints: Option<BoxConstraints>

Defines minimum and maximum sizes for a BottomSheet.

If null, then the ambient ThemeData.bottomSheetTheme’s BottomSheetThemeData::constraints will be used. If that is null and ThemeData.useMaterial3 is true, then the bottom sheet will have a max width of 640dp. If ThemeData.useMaterial3 is false, then the bottom sheet’s size will be constrained by its parent (usually a Scaffold). In this case, consider limiting the width by setting smaller constraints for large screens.

If constraints are specified (either in this property or in the theme), the bottom sheet will be aligned to the bottom-center of the available space. Otherwise, no alignment is applied.

Implementations§

Source§

impl BottomSheet

Source

pub fn new(on_closing: VoidCallback, builder: WidgetBuilder) -> BottomSheet

Creates a bottom sheet.

Typically, bottom sheets are created implicitly by ScaffoldState::show_bottom_sheet, for persistent bottom sheets, or by ShowModalBottomSheet, for modal bottom sheets.

Source

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

Dart BottomSheet(key:).

Source

pub fn animation_controller( self, animation_controller: Ref<AnimationController>, ) -> BottomSheet

Dart BottomSheet(animationController:).

Source

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

Dart BottomSheet(enableDrag:).

Source

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

Dart BottomSheet(showDragHandle:).

Source

pub fn drag_handle_color( self, drag_handle_color: impl Into<AnyColor>, ) -> BottomSheet

Dart BottomSheet(dragHandleColor:).

Source

pub fn drag_handle_size(self, drag_handle_size: Size) -> BottomSheet

Dart BottomSheet(dragHandleSize:).

Source

pub fn on_drag_start( self, on_drag_start: impl Fn(&mut App, DragStartDetails) + 'static, ) -> BottomSheet

Dart BottomSheet(onDragStart:).

Source

pub fn on_drag_end( self, on_drag_end: impl Fn(&mut App, DragEndDetails, bool) + 'static, ) -> BottomSheet

Dart BottomSheet(onDragEnd:).

Source

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

Dart BottomSheet(backgroundColor:).

Source

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

Dart BottomSheet(shadowColor:).

Source

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

Dart BottomSheet(elevation:).

Source

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

Dart BottomSheet(shape:).

Source

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

Dart BottomSheet(clipBehavior:).

Source

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

Dart BottomSheet(constraints:).

Source

pub fn create_animation_controller( app: &mut App, vsync: impl TickerProvider, sheet_animation_style: Option<&AnimationStyle>, ) -> Ref<AnimationController>

Creates an AnimationController suitable for a BottomSheet::animation_controller.

This API is available as a convenience for a Material compliant bottom sheet animation. If alternative animation durations are required, a different animation controller could be provided.

Trait Implementations§

Source§

impl Debug for BottomSheet

Source§

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

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

impl StatefulWidget for BottomSheet

Source§

type State = BottomSheetState

The state this widget creates.
Source§

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

Source§

fn create_state(&self) -> BottomSheetState

Creates the mutable state for this widget at a given location in the tree. 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)

Source§

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

Source§

fn type_name(&self) -> &'static str

See Widget::type_name. A stateful form another widget kind becomes (an animated or status transition widget) names the widget it wraps.

Auto Trait Implementations§

§

impl !RefUnwindSafe for BottomSheet

§

impl !Send for BottomSheet

§

impl !Sync for BottomSheet

§

impl !UnwindSafe for BottomSheet

§

impl Forget for BottomSheet

§

impl Freeze for BottomSheet
where *const RcInner<dyn Key> is !null: Freeze, PhantomData<RcInner<dyn Key>>: Freeze, NonZero<u32>: Freeze, PhantomData<fn() -> AnimationController>: Freeze, *const RcInner<Keep> is !null: Freeze, PhantomData<RcInner<Keep>>: Freeze, *const RcInner<dyn Fn(&mut App)> is !null: Freeze, PhantomData<RcInner<dyn Fn(&mut App)>>: Freeze, *const RcInner<dyn Fn(&mut App, AnyElement) -> Rc<dyn Widget>> is !null: Freeze, PhantomData<RcInner<dyn Fn(&mut App, AnyElement) -> Rc<dyn Widget>>>: Freeze, &'static dyn ColorExtension: Freeze, *const RcInner<dyn ColorExtension> is !null: Freeze, PhantomData<RcInner<dyn ColorExtension>>: Freeze, *const RcInner<dyn Fn(&mut App, DragStartDetails)> is !null: Freeze, PhantomData<RcInner<dyn Fn(&mut App, DragStartDetails)>>: Freeze, *const RcInner<dyn Fn(&mut App, DragEndDetails, bool)> is !null: Freeze, PhantomData<RcInner<dyn Fn(&mut App, DragEndDetails, bool)>>: Freeze, *const RcInner<dyn ShapeBorder> is !null: Freeze, PhantomData<RcInner<dyn ShapeBorder>>: Freeze,

§

impl Move for BottomSheet

§

impl Unpin for BottomSheet
where Rc<dyn Key>: Unpin, NonZero<u32>: Unpin, Rc<Keep>: Unpin, Rc<dyn Fn(&mut App)>: Unpin, Rc<dyn Fn(&mut App, AnyElement) -> Rc<dyn Widget>>: Unpin, &'static dyn ColorExtension: Unpin, Rc<dyn ColorExtension>: Unpin, Rc<dyn Fn(&mut App, DragStartDetails)>: Unpin, Rc<dyn Fn(&mut App, DragEndDetails, bool)>: Unpin, Rc<dyn ShapeBorder>: Unpin,

§

impl UnsafeUnpin for BottomSheet
where *const RcInner<dyn Key> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Key>>: UnsafeUnpin, NonZeroU32Inner: UnsafeUnpin, PhantomData<fn() -> AnimationController>: UnsafeUnpin, *const RcInner<Keep> is !null: UnsafeUnpin, PhantomData<RcInner<Keep>>: UnsafeUnpin, *const RcInner<dyn Fn(&mut App)> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Fn(&mut App)>>: UnsafeUnpin, *const RcInner<dyn Fn(&mut App, AnyElement) -> Rc<dyn Widget>> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Fn(&mut App, AnyElement) -> Rc<dyn Widget>>>: UnsafeUnpin, &'static dyn ColorExtension: UnsafeUnpin, *const RcInner<dyn ColorExtension> is !null: UnsafeUnpin, PhantomData<RcInner<dyn ColorExtension>>: UnsafeUnpin, *const RcInner<dyn Fn(&mut App, DragStartDetails)> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Fn(&mut App, DragStartDetails)>>: UnsafeUnpin, *const RcInner<dyn Fn(&mut App, DragEndDetails, bool)> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Fn(&mut App, DragEndDetails, bool)>>: UnsafeUnpin, *const RcInner<dyn ShapeBorder> is !null: UnsafeUnpin, PhantomData<RcInner<dyn ShapeBorder>>: 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<StatefulKind> for W
where W: StatefulWidget,

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>