ScrollFieldState


A state object that can be hoisted to observe and control the scrolling behavior of a ScrollField.

In most cases, this state should be created via rememberScrollFieldState.

Summary

Public constructors

ScrollFieldState(pagerState: PagerState, itemCount: Int)
Cmn

Public functions

suspend Unit

Animates the scroll to the specified option.

Cmn
suspend Unit

Instantly scrolls to the specified option.

Cmn

Public properties

Int

the total number of unique items available in the scroll field.

Cmn
Int

The index of the currently selected option.

Cmn

Public constructors

ScrollFieldState

ScrollFieldState(pagerState: PagerState, itemCount: Int)
Parameters
pagerState: PagerState

the underlying PagerState used to handle the scroll logic.

itemCount: Int

the total number of unique items available in the scroll field.

Public functions

animateScrollToOption

suspend fun animateScrollToOption(option: Int): Unit

Animates the scroll to the specified option.

Parameters
option: Int

the index of the item to animate to.

See also
scrollToOption

for an instant scroll.

scrollToOption

suspend fun scrollToOption(option: Int): Unit

Instantly scrolls to the specified option.

Parameters
option: Int

the index of the item to scroll to.

See also
animateScrollToOption

for a smooth transition.

Public properties

itemCount

val itemCountInt

the total number of unique items available in the scroll field.

selectedOption

val selectedOptionInt

The index of the currently selected option.

This value is always clamped between 0 and itemCount - 1. When the internal pager is scrolled, this value updates to reflect the item closest to the snap position.