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_sheetfunction or by specifying theScaffold::bottom_sheetconstructor 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
ShowModalBottomSheetfunction.
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:
- [
show_bottom_sheet] andScaffoldState::show_bottom_sheet, for showing non-modal “persistent” bottom sheets. ShowModalBottomSheet, which can be used to display a modal bottom sheet.BottomSheetThemeData, which can be used to customize the default bottom sheet property values.- 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.
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: VoidCallbackCalled 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: WidgetBuilderA builder for the contents of the sheet.
The bottom sheet will wrap the widget produced by this builder in a
Material widget.
enable_drag: boolIf 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: 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
impl BottomSheet
Sourcepub fn new(on_closing: VoidCallback, builder: WidgetBuilder) -> BottomSheet
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.
Sourcepub fn key(self, key: KeyRef) -> BottomSheet
pub fn key(self, key: KeyRef) -> BottomSheet
Dart BottomSheet(key:).
Sourcepub fn animation_controller(
self,
animation_controller: Ref<AnimationController>,
) -> BottomSheet
pub fn animation_controller( self, animation_controller: Ref<AnimationController>, ) -> BottomSheet
Dart BottomSheet(animationController:).
Sourcepub fn enable_drag(self, enable_drag: bool) -> BottomSheet
pub fn enable_drag(self, enable_drag: bool) -> BottomSheet
Dart BottomSheet(enableDrag:).
Sourcepub fn show_drag_handle(self, show_drag_handle: bool) -> BottomSheet
pub fn show_drag_handle(self, show_drag_handle: bool) -> BottomSheet
Dart BottomSheet(showDragHandle:).
Sourcepub fn drag_handle_color(
self,
drag_handle_color: impl Into<AnyColor>,
) -> BottomSheet
pub fn drag_handle_color( self, drag_handle_color: impl Into<AnyColor>, ) -> BottomSheet
Dart BottomSheet(dragHandleColor:).
Sourcepub fn drag_handle_size(self, drag_handle_size: Size) -> BottomSheet
pub fn drag_handle_size(self, drag_handle_size: Size) -> BottomSheet
Dart BottomSheet(dragHandleSize:).
Sourcepub fn on_drag_start(
self,
on_drag_start: impl Fn(&mut App, DragStartDetails) + 'static,
) -> BottomSheet
pub fn on_drag_start( self, on_drag_start: impl Fn(&mut App, DragStartDetails) + 'static, ) -> BottomSheet
Dart BottomSheet(onDragStart:).
Sourcepub fn on_drag_end(
self,
on_drag_end: impl Fn(&mut App, DragEndDetails, bool) + 'static,
) -> BottomSheet
pub fn on_drag_end( self, on_drag_end: impl Fn(&mut App, DragEndDetails, bool) + 'static, ) -> BottomSheet
Dart BottomSheet(onDragEnd:).
Sourcepub fn background_color(self, background_color: Color) -> BottomSheet
pub fn background_color(self, background_color: Color) -> BottomSheet
Dart BottomSheet(backgroundColor:).
Sourcepub fn shadow_color(self, shadow_color: Color) -> BottomSheet
pub fn shadow_color(self, shadow_color: Color) -> BottomSheet
Dart BottomSheet(shadowColor:).
Sourcepub fn elevation(self, elevation: f64) -> BottomSheet
pub fn elevation(self, elevation: f64) -> BottomSheet
Dart BottomSheet(elevation:).
Sourcepub fn shape(self, shape: impl Into<ShapeBorderRef>) -> BottomSheet
pub fn shape(self, shape: impl Into<ShapeBorderRef>) -> BottomSheet
Dart BottomSheet(shape:).
Sourcepub fn clip_behavior(self, clip_behavior: Clip) -> BottomSheet
pub fn clip_behavior(self, clip_behavior: Clip) -> BottomSheet
Dart BottomSheet(clipBehavior:).
Sourcepub fn constraints(self, constraints: BoxConstraints) -> BottomSheet
pub fn constraints(self, constraints: BoxConstraints) -> BottomSheet
Dart BottomSheet(constraints:).
Sourcepub fn create_animation_controller(
app: &mut App,
vsync: impl TickerProvider,
sheet_animation_style: Option<&AnimationStyle>,
) -> Ref<AnimationController>
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
impl Debug for BottomSheet
Source§impl StatefulWidget for BottomSheet
impl StatefulWidget for BottomSheet
Source§type State = BottomSheetState
type State = BottomSheetState
Source§fn create_state(&self) -> BottomSheetState
fn create_state(&self) -> BottomSheetState
Source§fn debug_fill_properties(
&self,
_app: &App,
properties: &mut DiagnosticPropertiesBuilder,
)
fn debug_fill_properties( &self, _app: &App, properties: &mut DiagnosticPropertiesBuilder, )
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 as_preferred_size_widget(
&self,
) -> Option<&(dyn PreferredSizeWidget + 'static)>
fn as_preferred_size_widget( &self, ) -> Option<&(dyn PreferredSizeWidget + 'static)>
Source§fn type_name(&self) -> &'static str
fn type_name(&self) -> &'static str
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 BottomSheetwhere
*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 BottomSheetwhere
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 BottomSheetwhere
*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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<W> IntoWidget<StatefulKind> for Wwhere
W: StatefulWidget,
impl<W> IntoWidget<StatefulKind> for Wwhere
W: StatefulWidget,
Source§fn into_widget(self) -> Rc<dyn Widget>
fn into_widget(self) -> Rc<dyn Widget>
creation_location.