PagerState

class PagerState(currentPage: Int = 0) : ScrollableState

A state object that can be hoisted to control and observe scrolling for HorizontalPager.

In most cases, this will be created via rememberPagerState.

Parameters

currentPage

the initial value for PagerState.currentPage

Constructors

Link copied to clipboard
fun PagerState(currentPage: Int = 0)

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
suspend fun animateScrollToPage(page: Int, pageOffset: Float = 0.0f)

Animate (smooth scroll) to the given page to the middle of the viewport.

suspend fun animateScrollToPage(    page: Int,     pageOffset: Float = 0.0f,     animationSpec: AnimationSpec<Float> = spring(),     initialVelocity: Float = 0.0f,     skipPages: Boolean = true)
Link copied to clipboard
open override fun dispatchRawDelta(delta: Float): Float
Link copied to clipboard
open suspend override fun scroll(scrollPriority: MutatePriority, block: suspend ScrollScope.() -> Unit)
Link copied to clipboard
suspend fun scrollToPage(page: Int, pageOffset: Float = 0.0f)

Instantly brings the item at page to the middle of the viewport.

Link copied to clipboard
open override fun toString(): String

Properties

Link copied to clipboard
var currentPage: Int

The index of the currently selected page. This may not be the page which is currently displayed on screen.

Link copied to clipboard
val currentPageOffset: Float

The current offset from the start of currentPage, as a ratio of the page width.

Link copied to clipboard
val interactionSource: InteractionSource

InteractionSource that will be used to dispatch drag events when this list is being dragged. If you want to know whether the fling (or animated scroll) is in progress, use isScrollInProgress.

Link copied to clipboard
open override val isScrollInProgress: Boolean
Link copied to clipboard
val pageCount: Int

The number of pages to display.

Link copied to clipboard
val targetPage: Int

The target page for any on-going animations or scrolls by the user. Returns the current page if a scroll or animation is not currently in progress.