NavBackStackSerializer

class NavBackStackSerializer<T : NavKey>(elementSerializer: KSerializer<T>) : KSerializer<NavBackStack<T>>

A KSerializer for NavBackStack.

This serializer wraps a KSerializer for the element type T, enabling serialization and deserialization of NavBackStack instances. The serialization of individual elements is delegated to the provided elementSerializer.

If your stack elements T are open polymorphic (e.g., a interface for different screens), the provided elementSerializer must be correctly configured to handle this.

Parameters

elementSerializer

The KSerializer used to serialize and deserialize individual elements.

Type Parameters

T

The type of elements stored in the NavBackStack.

Samples

androidx.navigation3.runtime.samples.NavBackStackSerializer_withReflection

Constructors

Link copied to clipboard
constructor(elementSerializer: KSerializer<T>)

Properties

Link copied to clipboard
open override val descriptor: SerialDescriptor

Functions

Link copied to clipboard
open override fun deserialize(decoder: Decoder): NavBackStack<T>
Link copied to clipboard
open override fun serialize(encoder: Encoder, value: NavBackStack<T>)