Skip to main content

PageController

Struct PageController 

Source
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

Source

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.

Source

pub fn default(app: &mut App) -> Ref<PageController>

Dart’s PageController(), with every argument at its default.

Source

pub fn initial_page(self: Handle<Self>, app: &App) -> i32

The page to show when first creating the PageView.

Source

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 the PageStorage locations used to save scroll offsets.
Source

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.

Source

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:

  1. No PageView is currently using this PageController. Once a PageView starts using this PageController, the new page position will be derived:

  2. More than one PageView using the same PageController.

The has_clients property can be used to check if a PageView is attached prior to accessing page.

Source

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.

Source

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.

Source

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.

Source

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

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.
Source§

impl ScrollControllerLeaf for PageController

Source§

fn scroll_controller_data( self: Handle<Self>, app: &App, ) -> &ScrollControllerData

Dart’s 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

Source§

fn create_scroll_position( self: Handle<Self>, app: &mut App, physics: ScrollPhysicsRef, context: Rc<dyn ScrollContext>, old_position: Option<AnyScrollPosition>, ) -> ScrollPositionRef

Creates a [ScrollPosition] for use by a Scrollable widget. Read more
Source§

fn attach(self: Handle<Self>, app: &mut App, position: ScrollPositionRef)

Register the given position with this controller. Read more
Source§

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

The initial value to use for offset. Read more
Source§

fn detach(self: Handle<Self>, app: &mut App, position: AnyScrollPosition)

Unregister the given position with this controller. Read more
Source§

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

Discards any resources used by the object.
Source§

fn debug_fill_description( self: Handle<Self>, app: &App, description: &mut Vec<String>, )

Add additional information to the given description for use by to_string. Read more
Source§

fn notification_listener(self: Handle<Self>) -> Listener

Dart’s notifyListeners tear-off: the listener this controller keeps on each attached position.
Source§

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

The body behind notification_listener.
Source§

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

Source§

fn on_attach(self: Handle<Self>, app: &App) -> Option<ScrollControllerCallback>

Source§

fn on_detach(self: Handle<Self>, app: &App) -> Option<ScrollControllerCallback>

Source§

fn debug_label(self: Handle<Self>, app: &App) -> Option<String>

Source§

fn positions(self: Handle<Self>, app: &App) -> Vec<AnyScrollPosition>

Source§

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

Source§

fn position(self: Handle<Self>, app: &App) -> AnyScrollPosition

Source§

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

Source§

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

Source§

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

Source§

fn to_string(self: Handle<Self>, app: &App) -> String

Source§

fn as_controller(self: Handle<Self>) -> AnyScrollController

This controller as the erased AnyScrollController — what to pass where a Dart API takes a ScrollController.

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>