pub struct PageView {Show 16 fields
pub key: Option<KeyRef>,
pub allow_implicit_scrolling: bool,
pub scroll_cache_extent: Option<ScrollCacheExtent>,
pub restoration_id: Option<String>,
pub scroll_direction: Axis,
pub reverse: bool,
pub controller: Option<Ref<PageController>>,
pub physics: Option<ScrollPhysicsRef>,
pub page_snapping: bool,
pub on_page_changed: Option<ValueChanged<i32>>,
pub children_delegate: SliverChildDelegateRef,
pub drag_start_behavior: DragStartBehavior,
pub clip_behavior: Clip,
pub hit_test_behavior: HitTestBehavior,
pub scroll_behavior: Option<ScrollBehaviorRef>,
pub pad_ends: bool,
}Expand description
A scrollable list that works page by page.
Each child of a page view is forced to be the same size as the viewport.
You can use a PageController to control which page is visible in the view. 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.
The PageController can also be used to control the
PageController::initial_page, which determines which page is shown when the
PageView is first constructed, and the PageController::viewport_fraction, which
determines the size of the pages as a fraction of the viewport size.
§Persisting the scroll position during a session
Scroll views attempt to persist their scroll position using PageStorage. For a
PageView, this can be disabled by setting PageController::keep_page to false on the
controller. If it is enabled, using a PageStorageKey for the
key of this widget is recommended to help disambiguate different scroll views
from each other.
See also:
PageController, which controls which page is visible in the view.SingleChildScrollView, when you need to make a single child scrollable.ListView, for a scrollable list of boxes.GridView, for a scrollable grid of boxes.ScrollNotificationandNotificationListener, which can be used to watch the scroll position without using aScrollController.
Fields§
§key: Option<KeyRef>§allow_implicit_scrolling: boolControls whether the widget’s pages will respond to RenderObject.showOnScreen, which
will allow for implicit accessibility scrolling.
With this flag set to false, when accessibility focus reaches the end of the current page and the user attempts to move it to the next element, the focus will traverse to the next widget outside of the page view.
With this flag set to true, when accessibility focus reaches the end of the current page and user attempts to move it to the next element, focus will traverse to the next page in the page view.
scroll_cache_extent: Option<ScrollCacheExtent>The amount of content to lay out around the visible pages; None until given.
In PageView, the default uses ScrollCacheExtent::Viewport, where the value
represents the number of viewport lengths to cache beyond the visible area.
When PageController::viewport_fraction is 1.0 (the default), this is equivalent to
the number of pages. For example, ScrollCacheExtent::Viewport(2.0) caches 2 pages
before and after the visible page.
When PageController::viewport_fraction is less than 1.0, multiple pages may be
visible in a single viewport, so ScrollCacheExtent::Viewport(1.0) may cache more than
one additional page in each direction.
ScrollCacheExtent::Pixels can also be used to specify the cache extent in logical
pixels instead of viewport sizes.
If it is given, its value must be consistent with
allow_implicit_scrolling: the value must be greater
than 0.0 when allow_implicit_scrolling is true, and
must be 0.0 when it is false.
Defaults to ScrollCacheExtent::Viewport(1.0) if
allow_implicit_scrolling is true, and
ScrollCacheExtent::Viewport(0.0) if it is false; read it through
effective_scroll_cache_extent.
restoration_id: Option<String>Restoration ID to save and restore the scroll offset of the scrollable.
scroll_direction: AxisThe Axis along which the scroll view’s offset increases with each page.
For the direction in which active scrolling may be occurring, see
ScrollDirection.
Defaults to Axis::Horizontal.
reverse: boolWhether the page view scrolls in the reading direction.
For example, if the reading direction is left-to-right and
scroll_direction is Axis::Horizontal, then the page view
scrolls from left to right when reverse is false and from right to
left when reverse is true.
Similarly, if scroll_direction is Axis::Vertical, then
the page view scrolls from top to bottom when reverse is false and
from bottom to top when reverse is true.
Defaults to false.
controller: Option<Ref<PageController>>An object that can be used to control the position to which this page view is scrolled.
physics: Option<ScrollPhysicsRef>How the page view should respond to user input.
For example, determines how the page view continues to animate after the user stops dragging the page view.
The physics are modified to snap to page boundaries using PageScrollPhysics prior
to being used.
If an explicit ScrollBehaviorRef is provided to
scroll_behavior, the ScrollPhysics provided by that
behavior will take precedence after physics.
Defaults to matching platform conventions.
page_snapping: boolSet to false to disable page snapping, useful for custom scroll behavior.
If the pad_ends is false and PageController::viewport_fraction <
1.0, the page will snap to the beginning of the viewport; otherwise, the page will snap
to the center of the viewport.
on_page_changed: Option<ValueChanged<i32>>Called whenever the page in the center of the viewport changes.
children_delegate: SliverChildDelegateRefA delegate that provides the children for the PageView.
The PageView::custom constructor lets you specify this delegate explicitly. The
PageView::new and PageView::builder constructors create a
children_delegate that wraps the given list and builder,
respectively.
drag_start_behavior: DragStartBehaviorDetermines the way that drag start behavior is handled.
clip_behavior: ClipThe content will be clipped (or not) according to this option.
Defaults to Clip::HardEdge.
hit_test_behavior: HitTestBehaviorDefines the behavior of gesture detector used in this Scrollable.
Defaults to HitTestBehavior::Opaque.
scroll_behavior: Option<ScrollBehaviorRef>A ScrollBehaviorRef that will be applied to this widget individually.
The scroll behavior of the inherited ScrollConfiguration will be modified by default
to not apply a scrollbar.
pad_ends: boolWhether to add padding to both ends of the list.
If this is set to true and PageController::viewport_fraction < 1.0, padding will be
added such that the first and last child slivers will be in the center of the viewport
when scrolled all the way to the start or end, respectively.
If PageController::viewport_fraction >= 1.0, this property has no effect.
This property defaults to true.
Implementations§
Source§impl PageView
impl PageView
Sourcepub fn new() -> PageView
pub fn new() -> PageView
Creates a scrollable list that works page by page from an explicit list of widgets,
which the children setter supplies.
This constructor is appropriate for page views with a small number of children because constructing the list requires doing work for every child that could possibly be displayed in the page view, instead of just those children that are actually visible.
Sourcepub fn builder(
item_builder: impl Fn(&mut App, BuildContext, i32) -> Option<WidgetRef> + 'static,
) -> PageViewBuilder
pub fn builder( item_builder: impl Fn(&mut App, BuildContext, i32) -> Option<WidgetRef> + 'static, ) -> PageViewBuilder
Creates a scrollable list that works page by page using widgets that are created on demand.
This constructor is appropriate for page views with a large (or infinite) number of children because the builder is called only for those children that are actually visible.
Providing an item_count lets the PageView compute
the maximum scroll extent.
The item builder will be called only with indices greater than or equal to zero and less than the item count.
Sourcepub fn custom(children_delegate: SliverChildDelegateRef) -> PageView
pub fn custom(children_delegate: SliverChildDelegateRef) -> PageView
Creates a scrollable list that works page by page with a custom child model.
Sourcepub fn children(self, children: impl IntoIterator<Item = WidgetRef>) -> PageView
pub fn children(self, children: impl IntoIterator<Item = WidgetRef>) -> PageView
Dart PageView(children:), which wraps the list in a SliverChildListDelegate.
Sourcepub fn scroll_direction(self, scroll_direction: Axis) -> PageView
pub fn scroll_direction(self, scroll_direction: Axis) -> PageView
Dart PageView(scrollDirection:).
Sourcepub fn controller(self, controller: Ref<PageController>) -> PageView
pub fn controller(self, controller: Ref<PageController>) -> PageView
Dart PageView(controller:).
Sourcepub fn physics(self, physics: ScrollPhysicsRef) -> PageView
pub fn physics(self, physics: ScrollPhysicsRef) -> PageView
Dart PageView(physics:).
Sourcepub fn page_snapping(self, page_snapping: bool) -> PageView
pub fn page_snapping(self, page_snapping: bool) -> PageView
Dart PageView(pageSnapping:).
Sourcepub fn on_page_changed(
self,
on_page_changed: impl Fn(&mut App, i32) + 'static,
) -> PageView
pub fn on_page_changed( self, on_page_changed: impl Fn(&mut App, i32) + 'static, ) -> PageView
Dart PageView(onPageChanged:).
Sourcepub fn drag_start_behavior(
self,
drag_start_behavior: DragStartBehavior,
) -> PageView
pub fn drag_start_behavior( self, drag_start_behavior: DragStartBehavior, ) -> PageView
Dart PageView(dragStartBehavior:).
Sourcepub fn allow_implicit_scrolling(
self,
allow_implicit_scrolling: bool,
) -> PageView
pub fn allow_implicit_scrolling( self, allow_implicit_scrolling: bool, ) -> PageView
Dart PageView(allowImplicitScrolling:).
Sourcepub fn scroll_cache_extent(
self,
scroll_cache_extent: ScrollCacheExtent,
) -> PageView
pub fn scroll_cache_extent( self, scroll_cache_extent: ScrollCacheExtent, ) -> PageView
Dart PageView(scrollCacheExtent:).
Sourcepub fn restoration_id(self, restoration_id: impl Into<String>) -> PageView
pub fn restoration_id(self, restoration_id: impl Into<String>) -> PageView
Dart PageView(restorationId:).
Sourcepub fn clip_behavior(self, clip_behavior: Clip) -> PageView
pub fn clip_behavior(self, clip_behavior: Clip) -> PageView
Dart PageView(clipBehavior:).
Sourcepub fn hit_test_behavior(self, hit_test_behavior: HitTestBehavior) -> PageView
pub fn hit_test_behavior(self, hit_test_behavior: HitTestBehavior) -> PageView
Dart PageView(hitTestBehavior:).
Sourcepub fn scroll_behavior(self, scroll_behavior: ScrollBehaviorRef) -> PageView
pub fn scroll_behavior(self, scroll_behavior: ScrollBehaviorRef) -> PageView
Dart PageView(scrollBehavior:).
Sourcepub fn effective_scroll_cache_extent(&self) -> ScrollCacheExtent
pub fn effective_scroll_cache_extent(&self) -> ScrollCacheExtent
Dart’s scrollCacheExtent field, as its constructor fills it.
Trait Implementations§
Source§impl StatefulWidget for PageView
impl StatefulWidget for PageView
Source§type State = PageViewState
type State = PageViewState
Source§fn create_state(&self) -> PageViewState
fn create_state(&self) -> PageViewState
Source§fn debug_fill_properties(
&self,
_app: &App,
properties: &mut DiagnosticPropertiesBuilder,
)
fn debug_fill_properties( &self, _app: &App, properties: &mut DiagnosticPropertiesBuilder, )
debugFillProperties: the properties a dump shows for this widget, in Dart’s
order. Dart’s Widget base only sets the dense tree style, which the framework does.Source§fn as_preferred_size_widget(&self) -> Option<&dyn PreferredSizeWidget>
fn as_preferred_size_widget(&self) -> Option<&dyn PreferredSizeWidget>
Source§fn type_name(&self) -> &'static str
fn type_name(&self) -> &'static str
Widget::type_name. A stateful form another widget kind becomes (an animated or
status transition widget) names the widget it wraps.Auto Trait Implementations§
impl !RefUnwindSafe for PageView
impl !Send for PageView
impl !Sync for PageView
impl !UnwindSafe for PageView
impl Forget for PageView
impl Freeze for PageViewwhere
*const RcInner<dyn Key> is !null: Freeze,
PhantomData<RcInner<dyn Key>>: Freeze,
*const u8 is !null: Freeze,
PhantomData<u8>: Freeze,
NonZero<u32>: Freeze,
PhantomData<fn() -> PageController>: Freeze,
*const RcInner<Keep> is !null: Freeze,
PhantomData<RcInner<Keep>>: Freeze,
*const RcInner<dyn ScrollPhysics> is !null: Freeze,
PhantomData<RcInner<dyn ScrollPhysics>>: Freeze,
*const RcInner<dyn Fn(&mut App, i32)> is !null: Freeze,
PhantomData<RcInner<dyn Fn(&mut App, i32)>>: Freeze,
*const RcInner<dyn SliverChildDelegate> is !null: Freeze,
PhantomData<RcInner<dyn SliverChildDelegate>>: Freeze,
*const RcInner<dyn ScrollBehavior> is !null: Freeze,
PhantomData<RcInner<dyn ScrollBehavior>>: Freeze,
impl Move for PageView
impl Unpin for PageView
impl UnsafeUnpin for PageViewwhere
*const RcInner<dyn Key> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Key>>: UnsafeUnpin,
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
NonZeroU32Inner: UnsafeUnpin,
PhantomData<fn() -> PageController>: UnsafeUnpin,
*const RcInner<Keep> is !null: UnsafeUnpin,
PhantomData<RcInner<Keep>>: UnsafeUnpin,
*const RcInner<dyn ScrollPhysics> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn ScrollPhysics>>: UnsafeUnpin,
*const RcInner<dyn Fn(&mut App, i32)> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Fn(&mut App, i32)>>: UnsafeUnpin,
*const RcInner<dyn SliverChildDelegate> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn SliverChildDelegate>>: UnsafeUnpin,
*const RcInner<dyn ScrollBehavior> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn ScrollBehavior>>: 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<W> IntoWidget<StatefulKind> for Wwhere
W: StatefulWidget,
impl<W> IntoWidget<StatefulKind> for Wwhere
W: StatefulWidget,
Source§fn into_widget(self) -> Rc<dyn Widget>
fn into_widget(self) -> Rc<dyn Widget>
creation_location.