mutableStateOf

fun <T> mutableStateOf(value: T, policy: SnapshotMutationPolicy<T> = structuralEqualityPolicy()): MutableState<T>

Return a new MutableState initialized with the passed in value

The MutableState class is a single value holder whose reads and writes are observed by Compose. Additionally, writes to it are transacted as part of the Snapshot system.

Samples

androidx.compose.runtime.samples.DestructuredStateSampleandroidx.compose.runtime.samples.observeUserSampleandroidx.compose.runtime.samples.SimpleStateSampleandroidx.compose.runtime.samples.stateSample

See also

Parameters

policy

a policy to controls how changes are handled in mutable snapshots.

value

the initial value for the MutableState