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: f64The 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: f64The minimum fractional value of the parent container’s height to use when displaying the widget.
The default value is 0.25.
max_child_size: f64The maximum fractional value of the parent container’s height to use when displaying the widget.
The default value is 1.0.
expand: boolWhether 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: boolWhether 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: boolWhether 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: ScrollableWidgetBuilderThe 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
impl DraggableScrollableSheet
Sourcepub fn new(builder: ScrollableWidgetBuilder) -> DraggableScrollableSheet
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.
Sourcepub fn key(self, key: KeyRef) -> DraggableScrollableSheet
pub fn key(self, key: KeyRef) -> DraggableScrollableSheet
Dart DraggableScrollableSheet(key:).
Sourcepub fn initial_child_size(
self,
initial_child_size: f64,
) -> DraggableScrollableSheet
pub fn initial_child_size( self, initial_child_size: f64, ) -> DraggableScrollableSheet
Dart DraggableScrollableSheet(initialChildSize:).
Sourcepub fn min_child_size(self, min_child_size: f64) -> DraggableScrollableSheet
pub fn min_child_size(self, min_child_size: f64) -> DraggableScrollableSheet
Dart DraggableScrollableSheet(minChildSize:).
Sourcepub fn max_child_size(self, max_child_size: f64) -> DraggableScrollableSheet
pub fn max_child_size(self, max_child_size: f64) -> DraggableScrollableSheet
Dart DraggableScrollableSheet(maxChildSize:).
Sourcepub fn expand(self, expand: bool) -> DraggableScrollableSheet
pub fn expand(self, expand: bool) -> DraggableScrollableSheet
Dart DraggableScrollableSheet(expand:).
Sourcepub fn snap(self, snap: bool) -> DraggableScrollableSheet
pub fn snap(self, snap: bool) -> DraggableScrollableSheet
Dart DraggableScrollableSheet(snap:).
Sourcepub fn snap_sizes(self, snap_sizes: Vec<f64>) -> DraggableScrollableSheet
pub fn snap_sizes(self, snap_sizes: Vec<f64>) -> DraggableScrollableSheet
Dart DraggableScrollableSheet(snapSizes:).
Sourcepub fn snap_animation_duration(
self,
duration: Duration,
) -> DraggableScrollableSheet
pub fn snap_animation_duration( self, duration: Duration, ) -> DraggableScrollableSheet
Dart DraggableScrollableSheet(snapAnimationDuration:).
Sourcepub fn controller(
self,
controller: Ref<DraggableScrollableController>,
) -> DraggableScrollableSheet
pub fn controller( self, controller: Ref<DraggableScrollableController>, ) -> DraggableScrollableSheet
Dart DraggableScrollableSheet(controller:).
Sourcepub fn should_close_on_min_extent(
self,
should_close_on_min_extent: bool,
) -> DraggableScrollableSheet
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
impl Debug for DraggableScrollableSheet
Source§impl StatefulWidget for DraggableScrollableSheet
impl StatefulWidget for DraggableScrollableSheet
Source§type State = DraggableScrollableSheetState
type State = DraggableScrollableSheetState
Source§fn create_state(&self) -> DraggableScrollableSheetState
fn create_state(&self) -> DraggableScrollableSheetState
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>
fn as_preferred_size_widget(&self) -> Option<&dyn PreferredSizeWidget>
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 DraggableScrollableSheet
impl !Send for DraggableScrollableSheet
impl !Sync for DraggableScrollableSheet
impl !UnwindSafe for DraggableScrollableSheet
impl Forget for DraggableScrollableSheet
impl Freeze for DraggableScrollableSheetwhere
*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
impl UnsafeUnpin for DraggableScrollableSheetwhere
*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> 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.