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<ScrollControllerCallback>,
on_detach: Option<ScrollControllerCallback>,
) -> Ref<ScrollController>
pub fn new( app: &mut App, initial_scroll_offset: f64, keep_scroll_offset: bool, debug_label: Option<String>, on_attach: Option<ScrollControllerCallback>, on_detach: Option<ScrollControllerCallback>, ) -> Ref<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) -> Ref<ScrollController>
pub fn default(app: &mut App) -> Ref<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: ScrollPositionRef,
)
pub fn attach( controller: AnyScrollController, app: &mut App, position: ScrollPositionRef, )
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: ScrollPhysicsRef,
context: Rc<dyn ScrollContext>,
old_position: Option<AnyScrollPosition>,
) -> ScrollPositionRef
pub fn create_scroll_position( controller: AnyScrollController, app: &mut App, physics: ScrollPhysicsRef, context: Rc<dyn ScrollContext>, old_position: Option<AnyScrollPosition>, ) -> ScrollPositionRef
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<Self>,
app: &App,
) -> &ScrollControllerData
fn scroll_controller_data( self: Handle<Self>, app: &App, ) -> &ScrollControllerData
ScrollController fields, held under the field scroll_controller
(scroll_controller_accessors!).Source§fn scroll_controller_data_mut(
self: Handle<Self>,
app: &mut App,
) -> &mut ScrollControllerData
fn scroll_controller_data_mut( self: Handle<Self>, app: &mut App, ) -> &mut ScrollControllerData
Source§fn attach(self: Handle<Self>, app: &mut App, position: ScrollPositionRef)
fn attach(self: Handle<Self>, app: &mut App, position: ScrollPositionRef)
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: ScrollPhysicsRef,
context: Rc<dyn ScrollContext>,
old_position: Option<AnyScrollPosition>,
) -> ScrollPositionRef
fn create_scroll_position( self: Handle<Self>, app: &mut App, physics: ScrollPhysicsRef, context: Rc<dyn ScrollContext>, old_position: Option<AnyScrollPosition>, ) -> ScrollPositionRef
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 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.