androidx.navigation3.runtime


Interfaces

NavKey

Marker interface for keys.

Cmn

Classes

EntryClassProvider

Holds a Entry class, metadata, and content for that class

Cmn
EntryProvider

Holds a Entry class, metadata, and content for that key

Cmn
EntryProviderBuilder

DSL for constructing a new NavEntry

Cmn
NavEntry

Entry maintains and stores the key and the content represented by that key.

Cmn
NavEntryDecorator

Marker class to hold the onPop and decorator functions that will be invoked at runtime.

Cmn
NavEntryWrapper

Class that wraps a NavEntry within another NavEntry.

Cmn

Annotations

EntryDsl
Cmn

Type aliases

NavBackStack

A List of objects that extend the NavKey marker class.

android

Top-level functions summary

Unit
@Composable
<T : Any> DecorateNavEntry(
    entry: NavEntry<T>,
    entryDecorators: List<NavEntryDecorator<*>>
)

Wraps a NavEntry with the list of NavEntryDecorator in the order that the decorators were added to the list and invokes the content of the wrapped entry.

Cmn
Unit
@Composable
<T : Any> DecoratedNavEntryProvider(
    backStack: List<T>,
    entryProvider: (key) -> NavEntry<T>,
    entryDecorators: List<NavEntryDecorator<*>>,
    content: @Composable (List<NavEntry<T>>) -> Unit
)

Function that provides all of the NavEntrys wrapped with the given NavEntryDecorators.

Cmn
NavEntryDecorator<Any>

Wraps the content of a NavEntry with a SaveableStateHolder.SaveableStateProvider to ensure that calls to rememberSaveable within the content work properly and that state can be saved.

Cmn
inline (T) -> NavEntry<T>
<T : Any> entryProvider(
    noinline fallback: (unknownScreen) -> NavEntry<T>,
    builder: EntryProviderBuilder<T>.() -> Unit
)

Creates an EntryProviderBuilder with the entry providers provided in the builder.

Cmn
NavEntryDecorator<T>
<T : Any> navEntryDecorator(
    onPop: (key: Any) -> Unit,
    decorator: @Composable (entry: NavEntry<T>) -> Unit
)

Function to provide information to all the NavEntry that are integrated with a DecoratedNavEntryProvider.

Cmn
SnapshotStateList<NavKey>
@Composable
<T : NavKey> rememberNavBackStack(vararg elements: T)

Provides a NavBackStack that is automatically remembered in the Compose hierarchy across process death and config changes.

android
NavEntryDecorator<Any>

Returns a SavedStateNavEntryDecorator that is remembered across recompositions.

Cmn

Extension functions summary

inline Unit
<T : Any> EntryProviderBuilder<*>.entry(
    metadata: Map<StringAny>,
    noinline content: @Composable (T) -> Unit
)

Add an entry provider to the EntryProviderBuilder

Cmn
Unit
<T : Any> EntryProviderBuilder<T>.entry(
    key: T,
    metadata: Map<StringAny>,
    content: @Composable (T) -> Unit
)

Add an entry provider to the EntryProviderBuilder

Cmn

Top-level functions

DecorateNavEntry

@Composable
fun <T : Any> DecorateNavEntry(
    entry: NavEntry<T>,
    entryDecorators: List<NavEntryDecorator<*>>
): Unit

Wraps a NavEntry with the list of NavEntryDecorator in the order that the decorators were added to the list and invokes the content of the wrapped entry.

DecoratedNavEntryProvider

@Composable
fun <T : Any> DecoratedNavEntryProvider(
    backStack: List<T>,
    entryProvider: (key) -> NavEntry<T>,
    entryDecorators: List<NavEntryDecorator<*>> = listOf(rememberSavedStateNavEntryDecorator()),
    content: @Composable (List<NavEntry<T>>) -> Unit
): Unit

Function that provides all of the NavEntrys wrapped with the given NavEntryDecorators. It is responsible for executing the functions provided by each NavEntryDecorator appropriately.

Note: the order in which the NavEntryDecorators are added to the list determines their scope, i.e. a NavEntryDecorator added earlier in a list has its data available to those added later.

Parameters
backStack: List<T>

the list of keys that represent the backstack

entryProvider: (key) -> NavEntry<T>

a function that returns the NavEntry for a given key

entryDecorators: List<NavEntryDecorator<*>> = listOf(rememberSavedStateNavEntryDecorator())

the NavEntryDecorators that are providing data to the content

content: @Composable (List<NavEntry<T>>) -> Unit

the content to be displayed

SavedStateNavEntryDecorator

fun SavedStateNavEntryDecorator(saveableStateHolder: SaveableStateHolder): NavEntryDecorator<Any>

Wraps the content of a NavEntry with a SaveableStateHolder.SaveableStateProvider to ensure that calls to rememberSaveable within the content work properly and that state can be saved. Also provides the content of a NavEntry with a SavedStateRegistryOwner which can be accessed in the content with LocalSavedStateRegistryOwner.

This NavEntryDecorator is the only one that is required as saving state is considered a non-optional feature.

inline fun <T : Any> entryProvider(
    noinline fallback: (unknownScreen) -> NavEntry<T> = { throw IllegalStateException("Unknown screen $it") },
    builder: EntryProviderBuilder<T>.() -> Unit
): (T) -> NavEntry<T>

Creates an EntryProviderBuilder with the entry providers provided in the builder.

fun <T : Any> navEntryDecorator(
    onPop: (key: Any) -> Unit = {},
    decorator: @Composable (entry: NavEntry<T>) -> Unit
): NavEntryDecorator<T>

Function to provide information to all the NavEntry that are integrated with a DecoratedNavEntryProvider.

Parameters
onPop: (key: Any) -> Unit = {}

a callback that provides the key of a NavEntry that has been popped from the backStack and is leaving composition. This optional callback should to be used to clean up states that were used to decorate the NavEntry3

decorator: @Composable (entry: NavEntry<T>) -> Unit

the composable function to provide information to a NavEntry. Note that this function only gets invoked for NavEntries that are actually getting rendered (i.e. by invoking the NavEntry.content.)

rememberNavBackStack

@Composable
fun <T : NavKey> rememberNavBackStack(vararg elements: T): SnapshotStateList<NavKey>

Provides a NavBackStack that is automatically remembered in the Compose hierarchy across process death and config changes.

Classes/objects added to the NavBackStack should be annotated with Serializable to ensure they can be saved and restored properly.

rememberSavedStateNavEntryDecorator

@Composable
fun rememberSavedStateNavEntryDecorator(
    saveableStateHolder: SaveableStateHolder = rememberSaveableStateHolder()
): NavEntryDecorator<Any>

Returns a SavedStateNavEntryDecorator that is remembered across recompositions.

Parameters
saveableStateHolder: SaveableStateHolder = rememberSaveableStateHolder()

the SaveableStateHolder that scopes the returned NavEntryDecorator

Extension functions

inline fun <T : Any> EntryProviderBuilder<*>.entry(
    metadata: Map<StringAny> = emptyMap(),
    noinline content: @Composable (T) -> Unit
): Unit

Add an entry provider to the EntryProviderBuilder

fun <T : Any> EntryProviderBuilder<T>.entry(
    key: T,
    metadata: Map<StringAny> = emptyMap(),
    content: @Composable (T) -> Unit
): Unit

Add an entry provider to the EntryProviderBuilder