Skip to main content

DraggableScrollableSheet

Struct DraggableScrollableSheet 

Source
pub struct DraggableScrollableSheet {
    pub key: Option<KeyRef>,
    pub initial_child_size: f64,
    pub min_child_size: f64,
    pub max_child_size: f64,
    pub expand: bool,
    pub snap: bool,
    pub snap_sizes: Option<Vec<f64>>,
    pub snap_animation_duration: Option<Duration>,
    pub controller: Option<Ref<DraggableScrollableController>>,
    pub should_close_on_min_extent: bool,
    pub builder: ScrollableWidgetBuilder,
}
Expand description

A container for a Scrollable that responds to drag gestures by resizing the scrollable until a limit is reached, and then scrolling.

This widget can be dragged along the vertical axis between its min_child_size, which defaults to 0.25 and max_child_size, which defaults to 1.0. These sizes are percentages of the height of the parent container.

The widget coordinates resizing and scrolling of the widget returned by builder as the user drags along the horizontal axis.

The widget will initially be displayed at its initial_child_size which defaults to 0.5, meaning half the height of its parent. Dragging will work between the range of min_child_size and max_child_size (as percentages of the parent container’s height) as long as the builder creates a widget which uses the provided scroll controller. If the widget created by the ScrollableWidgetBuilder does not use the provided controller, the sheet will remain at the initial child size.

By default, the widget will stay at whatever size the user drags it to. To make the widget snap to specific sizes whenever they lift their finger during a drag, set snap to true. The sheet will snap between min_child_size and max_child_size. Use snap_sizes to add more sizes for the sheet to snap between.

The snapping effect is only applied on user drags. Programmatically manipulating the sheet size via DraggableScrollableController::animate_to or DraggableScrollableController::jump_to will ignore snap and snap_sizes.

By default, the widget will expand its non-occupied area to fill available space in the parent. If this is not desired, e.g. because the parent wants to position sheet based on the space it is taking, the expand property may be set to false.

Fields§

§key: Option<KeyRef>

See Widget::key.

§initial_child_size: f64

The initial fractional value of the parent container’s height to use when displaying the widget.

Rebuilding the sheet with a new initial child size will only move the sheet to the new value if the sheet has not yet been dragged since it was first built or since the last call to DraggableScrollableActuator::reset.

The default value is 0.5.

§min_child_size: f64

The minimum fractional value of the parent container’s height to use when displaying the widget.

The default value is 0.25.

§max_child_size: f64

The maximum fractional value of the parent container’s height to use when displaying the widget.

The default value is 1.0.

§expand: bool

Whether the widget should expand to fill the available space in its parent or not.

In most cases, this should be true. However, in the case of a parent widget that will position this one based on its desired size (such as a Center), this should be set to false.

The default value is true.

§snap: bool

Whether the widget should snap between snap_sizes when the user lifts their finger during a drag.

If the user’s finger was still moving when they lifted it, the widget will snap to the next snap size in the direction of the drag. If their finger was still, the widget will snap to the nearest snap size.

Snapping is not applied when the sheet is programmatically moved by calling DraggableScrollableController::animate_to or DraggableScrollableController::jump_to.

Rebuilding the sheet with snap newly enabled will immediately trigger a snap unless the sheet has not yet been dragged away from initial_child_size since first being built or since the last call to DraggableScrollableActuator::reset.

§snap_sizes: Option<Vec<f64>>

A list of target sizes that the widget should snap to.

Snap sizes are fractional values of the parent container’s height. They must be listed in increasing order and be between min_child_size and max_child_size.

The minimum and maximum child sizes are implicitly included in snap sizes and do not need to be specified here.

§snap_animation_duration: Option<Duration>

Defines a duration for the snap animations.

If it’s not set, then the animation duration is the distance to the snap target divided by the velocity of the widget.

§controller: Option<Ref<DraggableScrollableController>>

A controller that can be used to programmatically control this sheet.

§should_close_on_min_extent: bool

Whether the sheet, when dragged (or flung) to its minimum size, should cause its parent sheet to close.

Set on emitted DraggableScrollableNotifications. It is up to parent widgets to properly read and handle this value.

§builder: ScrollableWidgetBuilder

The builder that creates a child to display in this widget, which will use the provided scroll controller to enable dragging and scrolling of the contents.

Implementations§

Source§

impl DraggableScrollableSheet

Source

pub fn new(builder: ScrollableWidgetBuilder) -> DraggableScrollableSheet

Creates a widget that can be dragged and scrolled in a single gesture; Dart’s optional arguments are the setters.

Dart’s defaults: initial_child_size 0.5, min_child_size 0.25, max_child_size 1.0, expand true, snap false, should_close_on_min_extent true.

Source

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

Dart DraggableScrollableSheet(key:).

Source

pub fn initial_child_size( self, initial_child_size: f64, ) -> DraggableScrollableSheet

Dart DraggableScrollableSheet(initialChildSize:).

Source

pub fn min_child_size(self, min_child_size: f64) -> DraggableScrollableSheet

Dart DraggableScrollableSheet(minChildSize:).

Source

pub fn max_child_size(self, max_child_size: f64) -> DraggableScrollableSheet

Dart DraggableScrollableSheet(maxChildSize:).

Source

pub fn expand(self, expand: bool) -> DraggableScrollableSheet

Dart DraggableScrollableSheet(expand:).

Source

pub fn snap(self, snap: bool) -> DraggableScrollableSheet

Dart DraggableScrollableSheet(snap:).

Source

pub fn snap_sizes(self, snap_sizes: Vec<f64>) -> DraggableScrollableSheet

Dart DraggableScrollableSheet(snapSizes:).

Source

pub fn snap_animation_duration( self, duration: Duration, ) -> DraggableScrollableSheet

Dart DraggableScrollableSheet(snapAnimationDuration:).

Source

pub fn controller( self, controller: Ref<DraggableScrollableController>, ) -> DraggableScrollableSheet

Dart DraggableScrollableSheet(controller:).

Source

pub fn should_close_on_min_extent( self, should_close_on_min_extent: bool, ) -> DraggableScrollableSheet

Dart DraggableScrollableSheet(shouldCloseOnMinExtent:).

Trait Implementations§

Source§

impl Debug for DraggableScrollableSheet

Source§

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

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

impl StatefulWidget for DraggableScrollableSheet

Source§

type State = DraggableScrollableSheetState

The state this widget creates.
Source§

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

Source§

fn create_state(&self) -> DraggableScrollableSheetState

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>

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 DraggableScrollableSheet

§

impl !Send for DraggableScrollableSheet

§

impl !Sync for DraggableScrollableSheet

§

impl !UnwindSafe for DraggableScrollableSheet

§

impl Forget for DraggableScrollableSheet

§

impl Freeze for DraggableScrollableSheet
where *const RcInner<dyn Key> is !null: Freeze, PhantomData<RcInner<dyn Key>>: Freeze, *const u8 is !null: Freeze, PhantomData<f64>: Freeze, NonZero<u32>: Freeze, PhantomData<fn() -> DraggableScrollableController>: Freeze, *const RcInner<Keep> is !null: Freeze, PhantomData<RcInner<Keep>>: Freeze, *const RcInner<dyn Fn(&mut App, AnyElement, Retained<AnyScrollController>) -> Rc<dyn Widget>> is !null: Freeze, PhantomData<RcInner<dyn Fn(&mut App, AnyElement, Retained<AnyScrollController>) -> Rc<dyn Widget>>>: Freeze,

§

impl Move for DraggableScrollableSheet

§

impl Unpin for DraggableScrollableSheet
where Rc<dyn Key>: Unpin, *const u8 is !null: Unpin, NonZero<u32>: Unpin, Rc<Keep>: Unpin, Rc<dyn Fn(&mut App, AnyElement, Retained<AnyScrollController>) -> Rc<dyn Widget>>: Unpin,

§

impl UnsafeUnpin for DraggableScrollableSheet
where *const RcInner<dyn Key> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Key>>: UnsafeUnpin, *const u8 is !null: UnsafeUnpin, PhantomData<f64>: UnsafeUnpin, NonZeroU32Inner: UnsafeUnpin, PhantomData<fn() -> DraggableScrollableController>: UnsafeUnpin, *const RcInner<Keep> is !null: UnsafeUnpin, PhantomData<RcInner<Keep>>: UnsafeUnpin, *const RcInner<dyn Fn(&mut App, AnyElement, Retained<AnyScrollController>) -> Rc<dyn Widget>> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Fn(&mut App, AnyElement, Retained<AnyScrollController>) -> Rc<dyn Widget>>>: 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>