# currentState

## Functions summary

|---|---|
| `inline T` | `@https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable <T : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?> https://developer.android.com/reference/kotlin/androidx/glance/currentState.composable#currentState()()` Retrieves the current customizable store for view specific state data as defined by `https://developer.android.com/reference/kotlin/androidx/glance/state/GlanceStateDefinition` in the surface implementation. |
| `inline T?` | `@https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable <T : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?> https://developer.android.com/reference/kotlin/androidx/glance/currentState.composable#currentState(androidx.datastore.preferences.core.Preferences.Key)(key: https://developer.android.com/reference/kotlin/androidx/datastore/preferences/core/Preferences.Key<T>)` Retrieves the current `https://developer.android.com/reference/kotlin/androidx/datastore/preferences/core/Preferences` value of the provided `https://developer.android.com/reference/kotlin/androidx/datastore/preferences/core/Preferences.Key` from the current state when `https://developer.android.com/reference/kotlin/androidx/datastore/preferences/core/Preferences` store is used as `https://developer.android.com/reference/kotlin/androidx/glance/state/GlanceStateDefinition` in the surface implementation. |

## Functions

### currentState

Artifact: [androidx.glance:glance](https://developer.android.com/jetpack/androidx/releases/glance) [View Source](https://cs.android.com/search?q=file:androidx/glance/CompositionLocals.kt+function:currentState)

```
@Composable
inline fun <T : Any?> currentState(): T
```

Retrieves the current customizable store for view specific state data as defined by `https://developer.android.com/reference/kotlin/androidx/glance/state/GlanceStateDefinition` in the surface implementation.

| Returns |
|---|---|
| `T` | the current store of the provided type `https://developer.android.com/reference/kotlin/androidx/glance/package-summary#currentState()` |

### currentState

Artifact: [androidx.glance:glance](https://developer.android.com/jetpack/androidx/releases/glance) [View Source](https://cs.android.com/search?q=file:androidx/glance/CompositionLocals.kt+function:currentState)

```
@Composable
inline fun <T : Any?> currentState(key: Preferences.Key<T>): T?
```

Retrieves the current `https://developer.android.com/reference/kotlin/androidx/datastore/preferences/core/Preferences` value of the provided `https://developer.android.com/reference/kotlin/androidx/datastore/preferences/core/Preferences.Key` from the current state when `https://developer.android.com/reference/kotlin/androidx/datastore/preferences/core/Preferences` store is used as `https://developer.android.com/reference/kotlin/androidx/glance/state/GlanceStateDefinition` in the surface implementation.

| Parameters |
|---|---|
| `key: https://developer.android.com/reference/kotlin/androidx/datastore/preferences/core/Preferences.Key<T>` | the `https://developer.android.com/reference/kotlin/androidx/datastore/preferences/core/Preferences.Key` to retrieve its value |

| Returns |
|---|---|
| `T?` | the stored value or null if not available. |