🌈 Create new beautiful Compose Gradients with our new wesite ->
Class

LazyGridState

Source set: Common
public class LazyGridState internal constructor(
    internal val legacyPrefetchStrategy: LazyGridPrefetchStrategy?,
    firstVisibleItemIndex: Int = 0,
    firstVisibleItemScrollOffset: Int = 0,
) : ScrollableState

Properties

firstVisibleItemIndex

Source set: Common
public val firstVisibleItemIndex: Int

The index of the first item that is visible within the scrollable viewport area, this means, not including items in the content padding region. For the first visible item that includes items in the content padding please use LazyGridLayoutInfo.visibleItemsInfo.

Note that this property is observable and if you use it in the composable function it will be recomposed on every change causing potential performance issues.

If you want to run some side effects like sending an analytics event or updating a state based on this value consider using "snapshotFlow":

If you need to use it in the composition then consider wrapping the calculation into a derived state in order to only have recompositions when the derived value changes:

firstVisibleItemScrollOffset

Source set: Common
public 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

layoutInfo

Source set: Common
public val layoutInfo: LazyGridLayoutInfo

The object of LazyGridLayoutInfo calculated during the last layout pass. For example, you can use it to calculate what items are currently visible.

Note that this property is observable and is updated after every scroll or remeasure. If you use it in the composable function it will be recomposed on every change causing potential performance issues including infinity recomposition loop. Therefore, avoid using it in the composition.

If you want to run some side effects like sending an analytics event or updating a state based on this value consider using "snapshotFlow":

interactionSource

Source set: Common
public val interactionSource: InteractionSource

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

Functions

scheduleLinePrefetch

Source set: Common
override fun scheduleLinePrefetch(
                lineIndex: Int
            ): List<LazyLayoutPrefetchState.PrefetchHandle>

scheduleLinePrefetch

Source set: Common
override fun scheduleLinePrefetch(
                lineIndex: Int,
                onPrefetchFinished: (LazyGridPrefetchResultScope.() -> Unit)?,
            ): List<LazyLayoutPrefetchState.PrefetchHandle>