pub struct PageController { /* private fields */ }Expand description
A controller for PageView.
A page controller lets you manipulate which page is visible in a PageView. In addition to
being able to control the pixel offset of the content inside the PageView, a
PageController also lets you control the offset in terms of pages, which are increments
of the viewport size.
See also:
PageView, which is the widget this object controls.
Implementations§
Source§impl PageController
impl PageController
Sourcepub fn new(
app: &mut App,
initial_page: i32,
keep_page: bool,
viewport_fraction: f64,
on_attach: Option<ScrollControllerCallback>,
on_detach: Option<ScrollControllerCallback>,
) -> Ref<PageController>
pub fn new( app: &mut App, initial_page: i32, keep_page: bool, viewport_fraction: f64, on_attach: Option<ScrollControllerCallback>, on_detach: Option<ScrollControllerCallback>, ) -> Ref<PageController>
Creates a page controller.
Dart’s defaults: initial_page 0, keep_page true, viewport_fraction 1.0, no
on_attach and no on_detach; PageController::default makes that one.
Sourcepub fn default(app: &mut App) -> Ref<PageController>
pub fn default(app: &mut App) -> Ref<PageController>
Dart’s PageController(), with every argument at its default.
Sourcepub fn initial_page(self: Handle<Self>, app: &App) -> i32
pub fn initial_page(self: Handle<Self>, app: &App) -> i32
The page to show when first creating the PageView.
Sourcepub fn keep_page(self: Handle<Self>, app: &App) -> bool
pub fn keep_page(self: Handle<Self>, app: &App) -> bool
Save the current page with PageStorage and restore it if this
controller’s scrollable is recreated.
If this property is set to false, the current page is never saved and
initial_page is always used to initialize the scroll offset. If
true (the default), the initial page is used the first time the controller’s scrollable
is created, since there’s isn’t a page to restore yet. Subsequently the saved page is
restored and initial_page is ignored.
See also:
PageStorageKey, which should be used when more than one scrollable appears in the same route, to distinguish thePageStoragelocations used to save scroll offsets.
Sourcepub fn viewport_fraction(self: Handle<Self>, app: &App) -> f64
pub fn viewport_fraction(self: Handle<Self>, app: &App) -> f64
The fraction of the viewport that each page should occupy.
Defaults to 1.0, which means each page fills the viewport in the scrolling direction.
Sourcepub fn page(self: Handle<Self>, app: &App) -> Option<f64>
pub fn page(self: Handle<Self>, app: &App) -> Option<f64>
The current page displayed in the controlled PageView.
There are circumstances that this PageController can’t know the current page.
Reading page will panic in the following cases:
-
No
PageViewis currently using thisPageController. Once aPageViewstarts using thisPageController, the newpageposition will be derived:- First, based on the attached
PageView’sBuildContextand the position saved at that context’sPageStorageifkeep_pageis true. - Second, from the
PageController’sinitial_page.
- First, based on the attached
-
More than one
PageViewusing the samePageController.
The has_clients property can be used to check if a
PageView is attached prior to accessing page.
Sourcepub fn animate_to_page(
self: Handle<Self>,
app: &mut App,
page: i32,
duration: Duration,
curve: Rc<dyn Curve>,
) -> CompleterFuture<()> ⓘ
pub fn animate_to_page( self: Handle<Self>, app: &mut App, page: i32, duration: Duration, curve: Rc<dyn Curve>, ) -> CompleterFuture<()> ⓘ
Animates the controlled PageView from the current page to the given page.
The animation lasts for the given duration and follows the given curve. The returned future resolves when the animation completes.
Sourcepub fn jump_to_page(self: Handle<Self>, app: &mut App, page: i32)
pub fn jump_to_page(self: Handle<Self>, app: &mut App, page: i32)
Changes which page is displayed in the controlled PageView.
Jumps the page position from its current value to the given value, without animation, and without checking if the new value is in range.
Sourcepub fn next_page(
self: Handle<Self>,
app: &mut App,
duration: Duration,
curve: Rc<dyn Curve>,
) -> CompleterFuture<()> ⓘ
pub fn next_page( self: Handle<Self>, app: &mut App, duration: Duration, curve: Rc<dyn Curve>, ) -> CompleterFuture<()> ⓘ
Animates the controlled PageView to the next page.
The animation lasts for the given duration and follows the given curve. The returned future resolves when the animation completes.
Sourcepub fn previous_page(
self: Handle<Self>,
app: &mut App,
duration: Duration,
curve: Rc<dyn Curve>,
) -> CompleterFuture<()> ⓘ
pub fn previous_page( self: Handle<Self>, app: &mut App, duration: Duration, curve: Rc<dyn Curve>, ) -> CompleterFuture<()> ⓘ
Animates the controlled PageView to the previous page.
The animation lasts for the given duration and follows the given curve. The returned future resolves when the animation completes.
Trait Implementations§
Source§impl ChangeNotifier for PageController
impl ChangeNotifier for PageController
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 PageController
impl ScrollControllerLeaf for PageController
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 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 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 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.