Skip to main content

DraggableScrollableController

Struct DraggableScrollableController 

Source
pub struct DraggableScrollableController { /* private fields */ }
Expand description

Controls a DraggableScrollableSheet.

Draggable scrollable controllers are typically stored as member variables in State objects and are reused in each State::build. Controllers can only be used to control one sheet at a time. A controller can be reused with a new sheet if the previous sheet has been disposed.

The controller’s methods cannot be used until after the controller has been passed into a DraggableScrollableSheet and the sheet has run init_state.

A DraggableScrollableController is a Listenable. It notifies its listeners whenever an attached sheet changes sizes. It does not notify its listeners when a sheet is first attached or when an attached sheet’s parameters change without affecting the sheet’s current size. It does not fire when pixels changes without size changing. For example, if the constraints provided to an attached sheet change.

Implementations§

Source§

impl DraggableScrollableController

Source

pub fn new(app: &mut App) -> Ref<DraggableScrollableController>

Creates a controller for DraggableScrollableSheet.

Source

pub fn size(self: Handle<Self>, app: &App) -> f64

Get the current size (as a fraction of the parent height) of the attached sheet.

Source

pub fn pixels(self: Handle<Self>, app: &App) -> f64

Get the current pixel height of the attached sheet.

Source

pub fn size_to_pixels(self: Handle<Self>, app: &App, size: f64) -> f64

Convert a sheet’s size (fractional value of parent container height) to pixels.

Source

pub fn is_attached(self: Handle<Self>, app: &App) -> bool

Whether a DraggableScrollableController has attached itself to a DraggableScrollableSheet.

If this is false, then members that interact with the ScrollPosition, such as size_to_pixels, size, animate_to, and jump_to, must not be called.

Source

pub fn pixels_to_size(self: Handle<Self>, app: &App, pixels: f64) -> f64

Convert a sheet’s pixel height to size (fractional value of parent container height).

Source

pub fn animate_to( self: Handle<Self>, app: &mut App, size: f64, duration: Duration, curve: Rc<dyn Curve>, ) -> CompleterFuture<()> ⓘ

Animates the attached sheet from its current size to the given size, a fractional value of the parent container’s height.

Any active sheet animation is canceled. If the sheet’s internal scrollable is currently animating (e.g. responding to a user fling), that animation is canceled as well.

An animation will be interrupted whenever the user attempts to scroll manually, whenever another activity is started, or when the sheet hits its max or min size (e.g. if you animate to 1 but the max size is .8, the animation will stop playing when it reaches .8).

The duration must not be zero. To jump to a particular value without an animation, use jump_to.

The sheet will not snap after calling animate_to even if DraggableScrollableSheet::snap is true. Snapping only occurs after user drags.

The returned future completes when the animation ends. An interrupted animation is stopped as canceled, so its future never completes — as Dart’s does not.

Source

pub fn jump_to(self: Handle<Self>, app: &mut App, size: f64)

Jumps the attached sheet from its current size to the given size, a fractional value of the parent container’s height.

If size is outside of the attached sheet’s min or max child size, jump_to will jump the sheet to the nearest valid size instead.

Any active sheet animation is canceled. If the sheet’s inner scrollable is currently animating (e.g. responding to a user fling), that animation is canceled as well.

The sheet will not snap after calling jump_to even if DraggableScrollableSheet::snap is true. Snapping only occurs after user drags.

Source

pub fn reset(self: Handle<Self>, app: &mut App)

Reset the attached sheet to its initial size (see DraggableScrollableSheet::initial_child_size).

Source

pub fn dispose(self: Handle<Self>, app: &mut App)

Discards any resources used by the object.

Trait Implementations§

Source§

impl ChangeNotifier for DraggableScrollableController

Source§

fn change_notifier_data(&self) -> &ChangeNotifierData

Source§

fn change_notifier_data_mut(&mut self) -> &mut ChangeNotifierData

Source§

fn will_add_listener(self: Handle<Self>, app: &mut App)

Runs before the listener is stored. Dart overrides of addListener that work before super.addListener go here.
Source§

fn did_remove_listener(self: Handle<Self>, app: &mut App)

Runs after the listener is removed. Dart overrides of removeListener that work after super.removeListener go here.

Auto Trait Implementations§

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> ListenableObject for T
where T: ChangeNotifier,

Source§

fn add_listener(self: Handle<T>, app: &mut App, listener: Listener)

Register a closure to be called when the object notifies its listeners.
Source§

fn remove_listener(self: Handle<T>, app: &mut App, listener: &Listener)

Remove a previously registered closure from the list of closures that the object notifies.
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>