# rememberLazyGridState

Common/All

## Functions summary

|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/grid/LazyGridState` | `@https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/grid/rememberLazyGridState.composable#rememberLazyGridState(kotlin.Int,kotlin.Int)( initialFirstVisibleItemIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, initialFirstVisibleItemScrollOffset: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html )` Creates a `https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/grid/LazyGridState` that is remembered across compositions. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/grid/LazyGridState` | `@https://developer.android.com/reference/kotlin/androidx/compose/foundation/ExperimentalFoundationApi @https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable [rememberLazyGridState](https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/grid/rememberLazyGridState.composable#rememberLazyGridState(androidx.compose.foundation.lazy.layout.LazyLayoutCacheWindow,kotlin.Int,kotlin.Int))( cacheWindow: https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/layout/LazyLayoutCacheWindow, initialFirstVisibleItemIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, initialFirstVisibleItemScrollOffset: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html )` **This function is deprecated.** Providing \`LazyLayoutCacheWindow\` via the \`Lazy\[Orientation\]Grid\` composable should be preferred over providing it via state. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/grid/LazyGridState` | `@https://developer.android.com/reference/kotlin/androidx/compose/foundation/ExperimentalFoundationApi @https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable [rememberLazyGridState](https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/grid/rememberLazyGridState.composable#rememberLazyGridState(kotlin.Int,kotlin.Int,androidx.compose.foundation.lazy.grid.LazyGridPrefetchStrategy))( initialFirstVisibleItemIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, initialFirstVisibleItemScrollOffset: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, prefetchStrategy: https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/grid/LazyGridPrefetchStrategy )` **This function is deprecated.** Providing \`LazyLayoutCacheWindow\` via the \`Lazy\[Orientation\]Grid\` composable should be preferred over using \`LazyGridPrefetchStrategy\` here. | Cmn |

## Functions

### rememberLazyGridState

Cmn Artifact: [androidx.compose.foundation:foundation](https://developer.android.com/jetpack/androidx/releases/compose-foundation) [View Source](https://cs.android.com/search?q=file:androidx/compose/foundation/lazy/grid/LazyGridState.kt+function:rememberLazyGridState) Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/compose-foundation#1.2.0)

```
@Composable
fun rememberLazyGridState(
    initialFirstVisibleItemIndex: Int = 0,
    initialFirstVisibleItemScrollOffset: Int = 0
): LazyGridState
```

Creates a `https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/grid/LazyGridState` that is remembered across compositions.

Changes to the provided initial values will **not** result in the state being recreated or changed in any way if it has already been created.

| Parameters |
|---|---|
| `initialFirstVisibleItemIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html = 0` | the initial value for `https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/grid/LazyGridState#firstVisibleItemIndex()` |
| `initialFirstVisibleItemScrollOffset: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html = 0` | the initial value for `https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/grid/LazyGridState#firstVisibleItemScrollOffset()` |

### rememberLazyGridState

Cmn Artifact: [androidx.compose.foundation:foundation](https://developer.android.com/jetpack/androidx/releases/compose-foundation) [View Source](https://cs.android.com/search?q=file:androidx/compose/foundation/lazy/grid/LazyGridState.kt+function:rememberLazyGridState) Added in [1.9.0](https://developer.android.com/jetpack/androidx/releases/compose-foundation#1.9.0) Deprecated in [1.13.0-rc01](https://developer.android.com/jetpack/androidx/releases/compose-foundation#1.13.0-rc01)

```
@ExperimentalFoundationApi
@Composable
fun [rememberLazyGridState](https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/grid/rememberLazyGridState.composable#rememberLazyGridState(androidx.compose.foundation.lazy.layout.LazyLayoutCacheWindow,kotlin.Int,kotlin.Int))(
    cacheWindow: LazyLayoutCacheWindow,
    initialFirstVisibleItemIndex: Int = 0,
    initialFirstVisibleItemScrollOffset: Int = 0
): LazyGridState
```

> [!CAUTION]
> **This function is deprecated.**   
> Providing \`LazyLayoutCacheWindow\` via the \`Lazy\[Orientation\]Grid\` composable should be preferred over providing it via state.

Creates a `https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/grid/LazyGridState` that is remembered across compositions.

Changes to the provided initial values will **not** result in the state being recreated or changed in any way if it has already been created.

| Parameters |
|---|---|
| `cacheWindow: https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/layout/LazyLayoutCacheWindow` | specifies the size of the ahead and behind window to be used as per `https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/layout/LazyLayoutCacheWindow`. |
| `initialFirstVisibleItemIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html = 0` | the initial value for `https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/grid/LazyGridState#firstVisibleItemIndex()` |
| `initialFirstVisibleItemScrollOffset: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html = 0` | the initial value for `https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/grid/LazyGridState#firstVisibleItemScrollOffset()` |

### rememberLazyGridState

Cmn Artifact: [androidx.compose.foundation:foundation](https://developer.android.com/jetpack/androidx/releases/compose-foundation) [View Source](https://cs.android.com/search?q=file:androidx/compose/foundation/lazy/grid/LazyGridState.kt+function:rememberLazyGridState) Added in [1.7.0](https://developer.android.com/jetpack/androidx/releases/compose-foundation#1.7.0) Deprecated in [1.13.0-rc01](https://developer.android.com/jetpack/androidx/releases/compose-foundation#1.13.0-rc01)

```
@ExperimentalFoundationApi
@Composable
fun [rememberLazyGridState](https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/grid/rememberLazyGridState.composable#rememberLazyGridState(kotlin.Int,kotlin.Int,androidx.compose.foundation.lazy.grid.LazyGridPrefetchStrategy))(
    initialFirstVisibleItemIndex: Int = 0,
    initialFirstVisibleItemScrollOffset: Int = 0,
    prefetchStrategy: LazyGridPrefetchStrategy = remember { LazyGridPrefetchStrategy() }
): LazyGridState
```

> [!CAUTION]
> **This function is deprecated.**   
> Providing \`LazyLayoutCacheWindow\` via the \`Lazy\[Orientation\]Grid\` composable should be preferred over using \`LazyGridPrefetchStrategy\` here.

Creates a `https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/grid/LazyGridState` that is remembered across compositions.

Changes to the provided initial values will **not** result in the state being recreated or changed in any way if it has already been created.

| Parameters |
|---|---|
| `initialFirstVisibleItemIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html = 0` | the initial value for `https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/grid/LazyGridState#firstVisibleItemIndex()` |
| `initialFirstVisibleItemScrollOffset: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html = 0` | the initial value for `https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/grid/LazyGridState#firstVisibleItemScrollOffset()` |
| `prefetchStrategy: https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/grid/LazyGridPrefetchStrategy = remember { LazyGridPrefetchStrategy() }` | the `https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/grid/LazyGridPrefetchStrategy` to use for prefetching content in this grid |