Google is committed to advancing racial equity for Black communities. See how.

LazyListState

@Stable class LazyListState
kotlin.Any
   ↳ androidx.compose.foundation.lazy.LazyListState

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

In most cases, this will be created via rememberLazyListState.

Summary

Public constructors
<init>(firstVisibleItemIndex: Int = 0, firstVisibleItemScrollOffset: Int = 0, interactionState: InteractionState? = null, flingConfig: FlingConfig, animationClock: AnimationClockObservable)

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

Companion functions
Saver<LazyListState, *>
Saver(flingConfig: FlingConfig, animationClock: AnimationClockObservable, interactionState: InteractionState?)

The default Saver implementation for LazyListState.

Properties
Int

The index of the first item that is visible

Int

The scroll offset of the first visible item.

Boolean

whether the Lazy list with this state is currently animating/flinging

Public constructors

<init>

LazyListState(
    firstVisibleItemIndex: Int = 0,
    firstVisibleItemScrollOffset: Int = 0,
    interactionState: InteractionState? = null,
    flingConfig: FlingConfig,
    animationClock: AnimationClockObservable)

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

In most cases, this will be created via rememberLazyListState.

Parameters
firstVisibleItemIndex: Int = 0 the initial value for LazyListState.firstVisibleItemIndex
firstVisibleItemScrollOffset: Int = 0 the initial value for
interactionState: InteractionState? = null InteractionState that will be updated when the element with this state is being scrolled by dragging, using Interaction.Dragged. If you want to know whether the fling (or smooth scroll) is in progress, use LazyListState.isAnimationRunning.
flingConfig: FlingConfig fling configuration to use for flinging
animationClock: AnimationClockObservable animation clock to run flinging and smooth scrolling on

Properties

firstVisibleItemIndex

val firstVisibleItemIndex: Int

The index of the first item that is visible

firstVisibleItemScrollOffset

val firstVisibleItemScrollOffset: Int

The scroll offset of the first visible item. Scrolling forward is positive - i.e., the amount that the item is offset backwards

isAnimationRunning

val isAnimationRunning: Boolean

whether the Lazy list with this state is currently animating/flinging

Companion functions

Saver

fun Saver(
    flingConfig: FlingConfig,
    animationClock: AnimationClockObservable,
    interactionState: InteractionState?
): Saver<LazyListState, *>

The default Saver implementation for LazyListState.