RetainedStateHolder

A holder that provides a unique retainedStateRegistry for each subtree and retains all preserved values. Each RetainedStateProvider maintains a unique retainedStateRegistry for each key, allowing it to save and restore states.

Functions

Link copied to clipboard
abstract fun removeState(key: String)

Removes the retained state associated with the passed key.

Link copied to clipboard
abstract fun RetainedStateProvider(key: String, content: @Composable () -> Unit)

Provides a RetainedStateRegistry for the child content based on the specified key. Before the provided registry is disposed, it calls RetainedStateRegistry.saveValue on the holder's registry to save the current value, allowing it to be restored on the next visit with the same key.