pub struct ScrollController { /* private fields */ }Expand description
Controls a scrollable widget.
Scroll controllers are typically stored as member variables in State
objects and are reused in each State::build. A single scroll controller can
be used to control multiple scrollable widgets, but some operations, such
as reading the scroll offset, require the controller to
be used with a single scrollable widget.
A scroll controller creates a [ScrollPosition] to manage the state specific
to an individual Scrollable widget. To use a custom [ScrollPosition],
write a second ScrollControllerLeaf that overrides
create_scroll_position.
Typically used with ListView, GridView, CustomScrollView.
The associated functions on this type are the shared bodies of Dart’s ScrollController;
a leaf calls one where Dart writes super.….
See also:
Scrollable, which is the lower-level widget that creates and associates [ScrollPosition] objects withScrollControllerobjects.- [
ScrollPosition], which manages the scroll offset for an individual scrolling widget. crate::ScrollNotificationandNotificationListener, which can be used to listen to scrolling occur without using aScrollController.
Implementations§
Source§impl ScrollController
impl ScrollController
Sourcepub fn new(
app: &mut App,
initial_scroll_offset: f64,
keep_scroll_offset: bool,
debug_label: Option<String>,
on_attach: Option<Rc<dyn Fn(&mut App, AnyScrollPosition)>>,
on_detach: Option<Rc<dyn Fn(&mut App, AnyScrollPosition)>>,
) -> Retained<Handle<ScrollController>>
pub fn new( app: &mut App, initial_scroll_offset: f64, keep_scroll_offset: bool, debug_label: Option<String>, on_attach: Option<Rc<dyn Fn(&mut App, AnyScrollPosition)>>, on_detach: Option<Rc<dyn Fn(&mut App, AnyScrollPosition)>>, ) -> Retained<Handle<ScrollController>>
Creates a controller for a scrollable widget.
Dart’s defaults: initial_scroll_offset 0.0, keep_scroll_offset true, and no
debug_label, on_attach or on_detach.
Sourcepub fn default(app: &mut App) -> Retained<Handle<ScrollController>>
pub fn default(app: &mut App) -> Retained<Handle<ScrollController>>
A controller with all of Dart’s defaults; ScrollController().
Sourcepub fn initial_scroll_offset(controller: AnyScrollController, app: &App) -> f64
pub fn initial_scroll_offset(controller: AnyScrollController, app: &App) -> f64
Sourcepub fn attach(
controller: AnyScrollController,
app: &mut App,
position: Retained<AnyScrollPosition>,
)
pub fn attach( controller: AnyScrollController, app: &mut App, position: Retained<AnyScrollPosition>, )
Sourcepub fn detach(
controller: AnyScrollController,
app: &mut App,
position: AnyScrollPosition,
)
pub fn detach( controller: AnyScrollController, app: &mut App, position: AnyScrollPosition, )
Sourcepub fn dispose(controller: AnyScrollController, app: &mut App)
pub fn dispose(controller: AnyScrollController, app: &mut App)
Sourcepub fn create_scroll_position(
controller: AnyScrollController,
app: &mut App,
physics: Rc<dyn ScrollPhysics>,
context: Rc<dyn ScrollContext>,
old_position: Option<AnyScrollPosition>,
) -> Retained<AnyScrollPosition>
pub fn create_scroll_position( controller: AnyScrollController, app: &mut App, physics: Rc<dyn ScrollPhysics>, context: Rc<dyn ScrollContext>, old_position: Option<AnyScrollPosition>, ) -> Retained<AnyScrollPosition>
Sourcepub fn debug_fill_description(
controller: AnyScrollController,
app: &App,
description: &mut Vec<String>,
)
pub fn debug_fill_description( controller: AnyScrollController, app: &App, description: &mut Vec<String>, )
Trait Implementations§
Source§impl ChangeNotifier for ScrollController
impl ChangeNotifier for ScrollController
fn change_notifier_data(&self) -> &ChangeNotifierData
fn change_notifier_data_mut(&mut self) -> &mut ChangeNotifierData
Source§fn will_add_listener(self: Handle<Self>, app: &mut App)
fn will_add_listener(self: Handle<Self>, app: &mut App)
addListener that
work before super.addListener go here.Source§fn did_remove_listener(self: Handle<Self>, app: &mut App)
fn did_remove_listener(self: Handle<Self>, app: &mut App)
removeListener that
work after super.removeListener go here.Source§impl ScrollControllerLeaf for ScrollController
impl ScrollControllerLeaf for ScrollController
Source§fn scroll_controller_data(
self: Handle<ScrollController>,
app: &App,
) -> &ScrollControllerData
fn scroll_controller_data( self: Handle<ScrollController>, app: &App, ) -> &ScrollControllerData
ScrollController fields, held under the field scroll_controller
(scroll_controller_accessors!).Source§fn scroll_controller_data_mut(
self: Handle<ScrollController>,
app: &mut App,
) -> &mut ScrollControllerData
fn scroll_controller_data_mut( self: Handle<ScrollController>, app: &mut App, ) -> &mut ScrollControllerData
Source§fn attach(
self: Handle<Self>,
app: &mut App,
position: Retained<AnyScrollPosition>,
)
fn attach( self: Handle<Self>, app: &mut App, position: Retained<AnyScrollPosition>, )
Source§fn detach(self: Handle<Self>, app: &mut App, position: AnyScrollPosition)
fn detach(self: Handle<Self>, app: &mut App, position: AnyScrollPosition)
Source§fn create_scroll_position(
self: Handle<Self>,
app: &mut App,
physics: Rc<dyn ScrollPhysics>,
context: Rc<dyn ScrollContext>,
old_position: Option<AnyScrollPosition>,
) -> Retained<AnyScrollPosition>
fn create_scroll_position( self: Handle<Self>, app: &mut App, physics: Rc<dyn ScrollPhysics>, context: Rc<dyn ScrollContext>, old_position: Option<AnyScrollPosition>, ) -> Retained<AnyScrollPosition>
Source§fn notification_listener(self: Handle<Self>) -> Listener
fn notification_listener(self: Handle<Self>) -> Listener
notifyListeners tear-off: the listener this controller keeps on each attached
position.Source§fn forward_notification(self: Handle<Self>, app: &mut App)
fn forward_notification(self: Handle<Self>, app: &mut App)
notification_listener.Source§fn on_attach(
self: Handle<Self>,
app: &App,
) -> Option<Rc<dyn Fn(&mut App, AnyScrollPosition)>>
fn on_attach( self: Handle<Self>, app: &App, ) -> Option<Rc<dyn Fn(&mut App, AnyScrollPosition)>>
Source§fn on_detach(
self: Handle<Self>,
app: &App,
) -> Option<Rc<dyn Fn(&mut App, AnyScrollPosition)>>
fn on_detach( self: Handle<Self>, app: &App, ) -> Option<Rc<dyn Fn(&mut App, AnyScrollPosition)>>
Source§fn animate_to(
self: Handle<Self>,
app: &mut App,
offset: f64,
duration: Duration,
curve: Rc<dyn Curve>,
) -> CompleterFuture<()> ⓘ
fn animate_to( self: Handle<Self>, app: &mut App, offset: f64, duration: Duration, curve: Rc<dyn Curve>, ) -> CompleterFuture<()> ⓘ
Source§fn as_controller(self: Handle<Self>) -> AnyScrollController
fn as_controller(self: Handle<Self>) -> AnyScrollController
AnyScrollController — what to pass where a Dart API
takes a ScrollController.Auto Trait Implementations§
impl !RefUnwindSafe for ScrollController
impl !Send for ScrollController
impl !Sync for ScrollController
impl !UnwindSafe for ScrollController
impl Forget for ScrollController
impl Freeze for ScrollControllerwhere
*const u8 is !null: Freeze,
PhantomData<Option<Listener>>: Freeze,
*const RcInner<Cell<usize>> is !null: Freeze,
PhantomData<RcInner<Cell<usize>>>: Freeze,
*const RcInner<dyn Fn(&mut App, AnyScrollPosition)> is !null: Freeze,
PhantomData<RcInner<dyn Fn(&mut App, AnyScrollPosition)>>: Freeze,
PhantomData<u8>: Freeze,
PhantomData<Retained<AnyScrollPosition>>: Freeze,
impl Move for ScrollController
impl Unpin for ScrollController
impl UnsafeUnpin for ScrollControllerwhere
*const u8 is !null: UnsafeUnpin,
PhantomData<Option<Listener>>: UnsafeUnpin,
*const RcInner<Cell<usize>> is !null: UnsafeUnpin,
PhantomData<RcInner<Cell<usize>>>: UnsafeUnpin,
*const RcInner<dyn Fn(&mut App, AnyScrollPosition)> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Fn(&mut App, AnyScrollPosition)>>: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
PhantomData<Retained<AnyScrollPosition>>: 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<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.