Source set: Common
@ExperimentalMaterial3ExpressiveApi
class ScrollFieldState(internal val pagerState: PagerState, val itemCount: Int)
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.
Parameters
| pagerState | the underlying PagerState used to handle the scroll logic. |
| itemCount | the total number of unique items available in the scroll field. |
Properties
selectedOption
Source set: Common
val selectedOption: Int
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.
Functions
scrollToOption
suspend fun scrollToOption(option: Int)
Instantly scrolls to the specified option.
Parameters
| option | the index of the item to scroll to. |
animateScrollToOption
suspend fun animateScrollToOption(option: Int)
Animates the scroll to the specified option.
Parameters
| option | the index of the item to animate to. |