currentState

Composable Function

Android
@Composable inline fun <reified T> currentState(): T

Retrieves the current customizable store for view specific state data as defined by GlanceStateDefinition in the surface implementation.

Returns

the current store of the provided type T
Android
@Composable
inline fun <reified T> currentState(key: Preferences.Key<T>): T?

Retrieves the current Preferences value of the provided Preferences.Key from the current state when Preferences store is used as GlanceStateDefinition in the surface implementation.

Parameters

keythe Preferences.Key to retrieve its value

Returns

the stored value or null if not available.