SavedStateWriter



An inline class that encapsulates an opaque SavedState, and provides an API for writing the platform specific state.

See also
write

Summary

Public functions

inline Unit

Removes all key-value pairs from the SavedState.

Cmn
android
inline Unit
putAll(values: SavedState)

Stores all key-value pairs from the provided SavedState into this SavedState.

Cmn
android
inline Unit
putBoolean(key: String, value: Boolean)

Stores a boolean value associated with the specified key in the SavedState.

Cmn
android
inline Unit
putDouble(key: String, value: Double)

Stores a double value associated with the specified key in the SavedState.

Cmn
android
inline Unit
putFloat(key: String, value: Float)

Stores a float value associated with the specified key in the SavedState.

Cmn
android
inline Unit
putInt(key: String, value: Int)

Stores an int value associated with the specified key in the SavedState.

Cmn
android
inline Unit
putIntList(key: String, values: List<Int>)

Stores a list of elements of Int associated with the specified key in the SavedState.

Cmn
android
inline Unit
<T : Parcelable> putParcelable(key: String, value: T)

Stores an Parcelable value associated with the specified key in the SavedState.

android
inline Unit
<T : Parcelable> putParcelableList(key: String, values: List<T>)

Stores a list of elements of Parcelable associated with the specified key in the SavedState.

android
inline Unit

Stores a SavedState object associated with the specified key in the SavedState.

Cmn
android
inline Unit
putString(key: String, value: String)

Stores a string value associated with the specified key in the SavedState.

Cmn
android
inline Unit
putStringList(key: String, values: List<String>)

Stores a list of elements of String associated with the specified key in the SavedState.

Cmn
android
inline Unit
remove(key: String)

Removes the value associated with the specified key from the SavedState.

Cmn
android

Extension functions

inline T
<T : Any?> SavedStateWriter.read(block: SavedStateReader.() -> T)

Calls the specified function block with a SavedStateReader value as its receiver and returns the block value.

Cmn

Public functions

clear

inline fun clear(): Unit

Removes all key-value pairs from the SavedState.

putAll

inline fun putAll(values: SavedState): Unit

Stores all key-value pairs from the provided SavedState into this SavedState.

Parameters
values: SavedState

The SavedState containing the key-value pairs to add.

putBoolean

inline fun putBoolean(key: String, value: Boolean): Unit

Stores a boolean value associated with the specified key in the SavedState.

Parameters
key: String

The key to associate the value with.

value: Boolean

The boolean value to store.

putDouble

inline fun putDouble(key: String, value: Double): Unit

Stores a double value associated with the specified key in the SavedState.

Parameters
key: String

The key to associate the value with.

value: Double

The double value to store.

putFloat

inline fun putFloat(key: String, value: Float): Unit

Stores a float value associated with the specified key in the SavedState.

Parameters
key: String

The key to associate the value with.

value: Float

The float value to store.

putInt

inline fun putInt(key: String, value: Int): Unit

Stores an int value associated with the specified key in the SavedState.

Parameters
key: String

The key to associate the value with.

value: Int

The int value to store.

putIntList

inline fun putIntList(key: String, values: List<Int>): Unit

Stores a list of elements of Int associated with the specified key in the SavedState.

Parameters
key: String

The key to associate the value with.

values: List<Int>

The list of elements to store.

putParcelable

inline fun <T : Parcelable> putParcelable(key: String, value: T): Unit

Stores an Parcelable value associated with the specified key in the SavedState.

Parameters
key: String

The key to associate the value with.

value: T

The Parcelable value to store.

putParcelableList

inline fun <T : Parcelable> putParcelableList(key: String, values: List<T>): Unit

Stores a list of elements of Parcelable associated with the specified key in the SavedState.

Parameters
key: String

The key to associate the value with.

values: List<T>

The list of elements to store.

putSavedState

inline fun putSavedState(key: String, value: SavedState): Unit

Stores a SavedState object associated with the specified key in the SavedState.

Parameters
key: String

The key to associate the value with.

value: SavedState

The SavedState object to store

putString

inline fun putString(key: String, value: String): Unit

Stores a string value associated with the specified key in the SavedState.

Parameters
key: String

The key to associate the value with.

value: String

The string value to store.

putStringList

inline fun putStringList(key: String, values: List<String>): Unit

Stores a list of elements of String associated with the specified key in the SavedState.

Parameters
key: String

The key to associate the value with.

values: List<String>

The list of elements to store.

remove

inline fun remove(key: String): Unit

Removes the value associated with the specified key from the SavedState.

Parameters
key: String

The key to remove.

Extension functions

inline fun <T : Any?> SavedStateWriter.read(block: SavedStateReader.() -> T): T

Calls the specified function block with a SavedStateReader value as its receiver and returns the block value.

Parameters
block: SavedStateReader.() -> T

A lambda function that performs read operations using the SavedStateReader.

Returns
T

The result of the lambda function's execution.