NavBackStackSerializer

Creates a NavBackStackSerializer for a polymorphic NavKey base type.

This factory function is a convenience for creating a serializer for a NavBackStack whose elements are polymorphic (e.g., different implementations of a NavKey interface).

It retrieves a base serializer for the element type T (which is typically the base NavKey interface).

Important: For polymorphic serialization to work, you must provide a SerializersModule (containing all concrete NavKey subtypes) to your Encoder/Decoder (e.g., via rememberSerializable).

kotlinx.serialization's polymorphic dispatch relies on the module available during the encoding/decoding process, not on the specific serializer retrieved by this function.

Return

A new NavBackStackSerializer configured for the base polymorphic type.

Type Parameters

T

The reified element type, typically the base NavKey interface.

Samples

androidx.navigation3.runtime.samples.NavBackStackSerializer_withSerializersModule