# GlimmerLazyListState

Artifact: [androidx.xr.glimmer:glimmer](https://developer.android.com/jetpack/androidx/releases/xr-glimmer) [View Source](https://cs.android.com/search?q=file:androidx/xr/glimmer/list/GlimmerLazyListState.kt+class:androidx.xr.glimmer.list.GlimmerLazyListState) Added in [1.0.0-alpha22](https://developer.android.com/jetpack/androidx/releases/xr-glimmer#1.0.0-alpha22)


```
class GlimmerLazyListState : ScrollableState
```

<br />

*** ** * ** ***

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

In most cases, this will be created via `https://developer.android.com/reference/kotlin/androidx/xr/glimmer/list/rememberGlimmerLazyListState.composable#rememberGlimmerLazyListState(kotlin.Int,kotlin.Int)`.

## Summary

| ### Public companion properties |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/runtime/saveable/Saver<https://developer.android.com/reference/kotlin/androidx/xr/glimmer/list/GlimmerLazyListState, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html>` | `https://developer.android.com/reference/kotlin/androidx/xr/glimmer/list/GlimmerLazyListState#Saver()` The default `https://developer.android.com/reference/kotlin/androidx/xr/glimmer/list/GlimmerLazyListState#Saver()` implementation for `https://developer.android.com/reference/kotlin/androidx/xr/glimmer/list/GlimmerLazyListState`. |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/xr/glimmer/list/GlimmerLazyListState#GlimmerLazyListState(kotlin.Int,kotlin.Int)( firstVisibleItemIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, firstVisibleItemScrollOffset: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html )` |

| ### Public functions |
|---|---|
| `suspend https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/xr/glimmer/list/GlimmerLazyListState#animateScrollToItem(kotlin.Int,kotlin.Int)(index: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, scrollOffset: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Animate (smooth scroll) to the given item. |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/xr/glimmer/list/GlimmerLazyListState#dispatchRawDelta(kotlin.Float)(delta: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)` |
| `open suspend https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/xr/glimmer/list/GlimmerLazyListState#scroll(androidx.compose.foundation.MutatePriority,kotlin.coroutines.SuspendFunction1)(scrollPriority: https://developer.android.com/reference/kotlin/androidx/compose/foundation/MutatePriority, block: suspend https://developer.android.com/reference/kotlin/androidx/compose/foundation/gestures/ScrollScope.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)` |
| `suspend https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/xr/glimmer/list/GlimmerLazyListState#scrollToItem(kotlin.Int,kotlin.Int)(index: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, scrollOffset: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Instantly brings the item at `https://developer.android.com/reference/kotlin/androidx/xr/glimmer/list/GlimmerLazyListState#scrollToItem(kotlin.Int,kotlin.Int)` to the top of the viewport, offset by `https://developer.android.com/reference/kotlin/androidx/xr/glimmer/list/GlimmerLazyListState#scrollToItem(kotlin.Int,kotlin.Int)` pixels. |

| ### Public properties |
|---|---|
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/xr/glimmer/list/GlimmerLazyListState#canScrollBackward()` |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/xr/glimmer/list/GlimmerLazyListState#canScrollForward()` |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/xr/glimmer/list/GlimmerLazyListState#firstVisibleItemIndex()` The index of the first item that is visible within the scrollable viewport area not including items in the content padding region. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/xr/glimmer/list/GlimmerLazyListState#firstVisibleItemScrollOffset()` The scroll offset of the first visible item. |
| `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/InteractionSource` | `https://developer.android.com/reference/kotlin/androidx/xr/glimmer/list/GlimmerLazyListState#interactionSource()` `https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/InteractionSource` that will be used to dispatch drag events when this list is being dragged. |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/xr/glimmer/list/GlimmerLazyListState#isScrollInProgress()` |
| `https://developer.android.com/reference/kotlin/androidx/xr/glimmer/list/GlimmerLazyListLayoutInfo` | `https://developer.android.com/reference/kotlin/androidx/xr/glimmer/list/GlimmerLazyListState#layoutInfo()` The object of `https://developer.android.com/reference/kotlin/androidx/xr/glimmer/list/GlimmerLazyListLayoutInfo` calculated during the last layout pass. |
| `open https://developer.android.com/reference/kotlin/androidx/compose/foundation/ScrollIndicatorState` | `https://developer.android.com/reference/kotlin/androidx/xr/glimmer/list/GlimmerLazyListState#scrollIndicatorState()` |

### Inherited properties

From [androidx.compose.foundation.gestures.ScrollableState](https://developer.android.com/reference/kotlin/androidx/compose/foundation/gestures/ScrollableState) `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/kotlin/androidx/compose/foundation/gestures/ScrollableState#lastScrolledBackward()` `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/kotlin/androidx/compose/foundation/gestures/ScrollableState#lastScrolledForward()`

## Public companion properties

### Saver

Added in [1.0.0-alpha22](https://developer.android.com/jetpack/androidx/releases/xr-glimmer#1.0.0-alpha22)

```
val Saver: Saver<GlimmerLazyListState, Any>
```

The default `https://developer.android.com/reference/kotlin/androidx/xr/glimmer/list/GlimmerLazyListState#Saver()` implementation for `https://developer.android.com/reference/kotlin/androidx/xr/glimmer/list/GlimmerLazyListState`.

## Public constructors

### GlimmerLazyListState

Added in [1.0.0-alpha22](https://developer.android.com/jetpack/androidx/releases/xr-glimmer#1.0.0-alpha22)

```
GlimmerLazyListState(
    firstVisibleItemIndex: Int = 0,
    firstVisibleItemScrollOffset: Int = 0
)
```

| Parameters |
|---|---|
| `firstVisibleItemIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html = 0` | the initial value for `https://developer.android.com/reference/kotlin/androidx/xr/glimmer/list/GlimmerLazyListState#firstVisibleItemIndex()` |
| `firstVisibleItemScrollOffset: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html = 0` | the initial value for `https://developer.android.com/reference/kotlin/androidx/xr/glimmer/list/GlimmerLazyListState#firstVisibleItemScrollOffset()` |

## Public functions

### animateScrollToItem

Added in [1.0.0-alpha22](https://developer.android.com/jetpack/androidx/releases/xr-glimmer#1.0.0-alpha22)

```
suspend fun animateScrollToItem(index: @IntRange(from = 0) Int, scrollOffset: Int = 0): Unit
```

Animate (smooth scroll) to the given item.

| Parameters |
|---|---|
| `index: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | the index to which to scroll. Must be non-negative. |
| `scrollOffset: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html = 0` | the offset that the item should end up after the scroll. Note that positive offset refers to forward scroll, so in a top-to-bottom list, positive offset will scroll the item further upward (taking it partly offscreen). |

### dispatchRawDelta

Added in [1.0.0-alpha22](https://developer.android.com/jetpack/androidx/releases/xr-glimmer#1.0.0-alpha22)

```
open fun dispatchRawDelta(delta: Float): Float
```

### scroll

Added in [1.0.0-alpha22](https://developer.android.com/jetpack/androidx/releases/xr-glimmer#1.0.0-alpha22)

```
open suspend fun scroll(scrollPriority: MutatePriority, block: suspend ScrollScope.() -> Unit): Unit
```

### scrollToItem

Added in [1.0.0-alpha22](https://developer.android.com/jetpack/androidx/releases/xr-glimmer#1.0.0-alpha22)

```
suspend fun scrollToItem(index: @IntRange(from = 0) Int, scrollOffset: Int = 0): Unit
```

Instantly brings the item at `https://developer.android.com/reference/kotlin/androidx/xr/glimmer/list/GlimmerLazyListState#scrollToItem(kotlin.Int,kotlin.Int)` to the top of the viewport, offset by `https://developer.android.com/reference/kotlin/androidx/xr/glimmer/list/GlimmerLazyListState#scrollToItem(kotlin.Int,kotlin.Int)` pixels.

| Parameters |
|---|---|
| `index: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | the index to which to scroll. Must be non-negative. |
| `scrollOffset: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html = 0` | the offset that the item should end up after the scroll. Note that positive offset refers to forward scroll, so in a top-to-bottom list, positive offset will scroll the item further upward (taking it partly offscreen). |

## Public properties

### canScrollBackward

```
open val canScrollBackward: Boolean
```

### canScrollForward

```
open val canScrollForward: Boolean
```

### firstVisibleItemIndex

Added in [1.0.0-alpha22](https://developer.android.com/jetpack/androidx/releases/xr-glimmer#1.0.0-alpha22)

```
val firstVisibleItemIndex: Int
```

The index of the first item that is visible within the scrollable viewport area not including items in the content padding region. For the first visible item that includes items in the content padding please use `https://developer.android.com/reference/kotlin/androidx/xr/glimmer/list/GlimmerLazyListLayoutInfo#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.

### firstVisibleItemScrollOffset

Added in [1.0.0-alpha22](https://developer.android.com/jetpack/androidx/releases/xr-glimmer#1.0.0-alpha22)

```
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.

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

### interactionSource

Added in [1.0.0-alpha22](https://developer.android.com/jetpack/androidx/releases/xr-glimmer#1.0.0-alpha22)

```
val interactionSource: InteractionSource
```

`https://developer.android.com/reference/kotlin/androidx/compose/foundation/interaction/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 `https://developer.android.com/reference/kotlin/androidx/xr/glimmer/list/GlimmerLazyListState#isScrollInProgress()`.

### isScrollInProgress

Added in [1.0.0-alpha22](https://developer.android.com/jetpack/androidx/releases/xr-glimmer#1.0.0-alpha22)

```
open val isScrollInProgress: Boolean
```

### layoutInfo

Added in [1.0.0-alpha22](https://developer.android.com/jetpack/androidx/releases/xr-glimmer#1.0.0-alpha22)

```
val layoutInfo: GlimmerLazyListLayoutInfo
```

The object of `https://developer.android.com/reference/kotlin/androidx/xr/glimmer/list/GlimmerLazyListLayoutInfo` 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":

### scrollIndicatorState

```
open val scrollIndicatorState: ScrollIndicatorState
```