key
key is a utility composable that is used to "group" or "key" a block of execution inside of a composition. This is sometimes needed for correctness inside of control-flow that may cause a given composable invocation to execute more than once during composition.
The value for a key does not need to be globally unique, and needs only be unique amongst the invocations of keyat that point in composition.
For instance, consider the following example:
Samples
androidx.compose.runtime.samples.LocallyUniqueKeysandroidx.compose.runtime.samples.MoreCorrectUniqueKeysandroidx.compose.runtime.samples.NotAlwaysUniqueKeysandroidx.compose.runtime.samples.TwoInputsKeySample