listSaver
Function
Common
public fun <Original, Saveable> listSaver(
save: SaverScope.(value: Original) -> List<Saveable>,
restore: (list: List<Saveable>) -> Original?,
): Saver<Original, Any>
The Saver implementation which allows to represent your Original class as a list of
Saveable values.
What types can be saved is defined by SaveableStateRegistry, by default everything which can be
stored in the Bundle class can be saved.
You can use it as a parameter for rememberSaveable.
Code Examples
ListSaverSample
@Composable
fun ListSaverSample() {
data class Size(val x: Int, val y: Int)
val sizeSaver =
listSaver<Size, Int>(save = { listOf(it.x, it.y) }, restore = { Size(it[0], it[1]) })
}
