NavBackStack
class NavBackStack<T : NavKey>(base: SnapshotStateList<T>) : MutableList<T> , StateObject, RandomAccess
A mutable back stack of NavKey elements that integrates with Compose state.
This class wraps a SnapshotStateList so that updates to the stack automatically trigger recomposition in any observing Composables. It also implements StateObject, which allows it to participate in Compose's snapshot system directly.
Typically, you won’t construct a NavBackStack manually. Instead, prefer using rememberNavBackStack, which provides a stack that is automatically saved and restored across process death and configuration changes.
Example
val backStack = NavBackStack(Home("start"))
backStack += Details("item42") // pushes onto stack
backStack.removeLast() // pops stackContent copied to clipboard
See also
for lifecycle-aware persistence.
Samples
androidx.navigation3.runtime.samples.NavBackStack_OpenPolymorphismandroidx.navigation3.runtime.samples.NavBackStack_ClosedPolymorphismConstructors
Link copied to clipboard
Creates a new back stack backed by the provided SnapshotStateList.
constructor()
Functions
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open override fun mergeRecords(previous: StateRecord, current: StateRecord, applied: StateRecord): StateRecord?
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard