SavedStateWriter


value public final class SavedStateWriter


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

See also
write

Summary

Public methods

final void

Removes all key-value pairs from the SavedState.

final void

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

final void
putBoolean(@NonNull String key, boolean value)

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

final void
putChar(@NonNull String key, char value)
final void
putDouble(@NonNull String key, double value)

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

final void
putFloat(@NonNull String key, float value)

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

final void
putInt(@NonNull String key, int value)

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

final void

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

final void
putLong(@NonNull String key, long value)

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

final void

Stores a null reference associated with the specified key in the SavedState.

final void
<T extends Parcelable> putParcelable(@NonNull String key, @NonNull T value)

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

final void
<T extends Parcelable> putParcelableList(
    @NonNull String key,
    @NonNull List<@NonNull T> values
)

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

final void

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

final void

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

final void

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

final void

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

Extension functions

final @NonNull T
<T extends Object> SavedStateKt.read(
    @NonNull SavedStateWriter receiver,
    @ExtensionFunctionType @NonNull Function1<@NonNull SavedStateReader, @NonNull T> block
)

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

Public methods

clear

Added in 1.3.0-alpha04
public final void clear()

Removes all key-value pairs from the SavedState.

putAll

public final void putAll(@NonNull SavedState values)

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

Parameters
@NonNull SavedState values

The SavedState containing the key-value pairs to add.

putBoolean

Added in 1.3.0-alpha04
public final void putBoolean(@NonNull String key, boolean value)

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

Parameters
@NonNull String key

The key to associate the value with.

boolean value

The boolean value to store.

putChar

Added in 1.3.0-alpha04
public final void putChar(@NonNull String key, char value)

putDouble

Added in 1.3.0-alpha04
public final void putDouble(@NonNull String key, double value)

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

Parameters
@NonNull String key

The key to associate the value with.

double value

The double value to store.

putFloat

Added in 1.3.0-alpha04
public final void putFloat(@NonNull String key, float value)

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

Parameters
@NonNull String key

The key to associate the value with.

float value

The float value to store.

putInt

Added in 1.3.0-alpha04
public final void putInt(@NonNull String key, int value)

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

Parameters
@NonNull String key

The key to associate the value with.

int value

The int value to store.

putIntList

Added in 1.3.0-alpha04
public final void putIntList(@NonNull String key, @NonNull List<@NonNull Integer> values)

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

Parameters
@NonNull String key

The key to associate the value with.

@NonNull List<@NonNull Integer> values

The list of elements to store.

putLong

Added in 1.3.0-alpha04
public final void putLong(@NonNull String key, long value)

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

Parameters
@NonNull String key

The key to associate the value with.

long value

The Long value to store.

putNull

Added in 1.3.0-alpha04
public final void putNull(@NonNull String key)

Stores a null reference associated with the specified key in the SavedState.

Parameters
@NonNull String key

The key to associate the null reference.

putParcelable

public final void <T extends Parcelable> putParcelable(@NonNull String key, @NonNull T value)

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

Parameters
@NonNull String key

The key to associate the value with.

@NonNull T value

The Parcelable value to store.

putParcelableList

public final void <T extends Parcelable> putParcelableList(
    @NonNull String key,
    @NonNull List<@NonNull T> values
)

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

Parameters
@NonNull String key

The key to associate the value with.

@NonNull List<@NonNull T> values

The list of elements to store.

putSavedState

public final void putSavedState(@NonNull String key, @NonNull SavedState value)

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

Parameters
@NonNull String key

The key to associate the value with.

@NonNull SavedState value

The SavedState object to store

putString

Added in 1.3.0-alpha04
public final void putString(@NonNull String key, @NonNull String value)

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

Parameters
@NonNull String key

The key to associate the value with.

@NonNull String value

The string value to store.

putStringList

Added in 1.3.0-alpha04
public final void putStringList(@NonNull String key, @NonNull List<@NonNull String> values)

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

Parameters
@NonNull String key

The key to associate the value with.

@NonNull List<@NonNull String> values

The list of elements to store.

remove

Added in 1.3.0-alpha04
public final void remove(@NonNull String key)

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

Parameters
@NonNull String key

The key to remove.

Extension functions

SavedStateKt.read

public final @NonNull T <T extends Object> SavedStateKt.read(
    @NonNull SavedStateWriter receiver,
    @ExtensionFunctionType @NonNull Function1<@NonNull SavedStateReader, @NonNull T> block
)

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

Parameters
@ExtensionFunctionType @NonNull Function1<@NonNull SavedStateReader, @NonNull T> block

A lambda function that performs read operations using the SavedStateReader.

Returns
@NonNull T

The result of the lambda function's execution.