NavBackStackEntry
Representation of an entry in the back stack of a androidx.navigation.NavController. The Lifecycle, ViewModelStore, and SavedStateRegistry provided via this object are valid for the lifetime of this destination on the back stack: when this destination is popped off the back stack, the lifecycle will be destroyed, state will no longer be saved, and ViewModels will be cleared.
Summary
Public functions |
||
|---|---|---|
open operator Boolean |
android
|
|
open Int |
hashCode() |
android
|
open String |
toString() |
android
|
Public properties |
||
|---|---|---|
SavedState? |
The arguments used for this entry. |
Cmn
android
|
open CreationExtras |
Returns the default |
Cmn
android
|
open ViewModelProvider.Factory |
Returns the default |
Cmn
android
|
NavDestination |
The destination associated with this entry |
Cmn
android
|
String |
The unique ID that serves as the identity of this entry |
Cmn
android
|
open Lifecycle |
{@inheritDoc} |
Cmn
android
|
SavedStateHandle |
The |
Cmn
android
|
open SavedStateRegistry |
The |
Cmn
android
|
open ViewModelStore |
{@inheritDoc} |
Cmn
android
|
Extension functions |
||
|---|---|---|
inline T |
<T : Any?> NavBackStackEntry.toRoute()Returns route as an object of type |
Cmn
|
T |
<T : Any?> NavBackStackEntry.toRoute(route: KClass<*>)Returns route as an object of type |
Cmn
|
Unit |
@ComposableProvides |
Cmn
|
Public properties
arguments
val arguments: SavedState?
The arguments used for this entry. Note that the arguments of a NavBackStackEntry are immutable and defined when you navigate() to the destination - changes you make to this SavedState will not be reflected in future calls to this property.
| Returns | |
|---|---|
SavedState? |
The arguments used when this entry was created |
defaultViewModelCreationExtras
open val defaultViewModelCreationExtras: CreationExtras
Returns the default CreationExtras that should be passed into ViewModelProvider.Factory.create when no overriding CreationExtras were passed to the ViewModelProvider constructors.
defaultViewModelProviderFactory
open val defaultViewModelProviderFactory: ViewModelProvider.Factory
Returns the default ViewModelProvider.Factory that should be used when no custom Factory is provided to the ViewModelProvider constructors.
destination
val destination: NavDestination
The destination associated with this entry
| Returns | |
|---|---|
NavDestination |
The destination that is currently visible to users |
id
val id: String
The unique ID that serves as the identity of this entry
| Returns | |
|---|---|
String |
the unique ID of this entry |
lifecycle
open val lifecycle: Lifecycle
{@inheritDoc}
If the androidx.navigation.NavHost has not called androidx.navigation.NavHostController.setLifecycleOwner, the Lifecycle will be capped at Lifecycle.State.CREATED.
savedStateRegistry
open val savedStateRegistry: SavedStateRegistry
The SavedStateRegistry owned by this SavedStateRegistryOwner
viewModelStore
open val viewModelStore: ViewModelStore
{@inheritDoc}
| Throws | |
|---|---|
kotlin.IllegalStateException |
if called before the |
Extension functions
toRoute
inline fun <T : Any?> NavBackStackEntry.toRoute(): T
Returns route as an object of type T
Extrapolates arguments from NavBackStackEntry.arguments and recreates object T
| Parameters | |
|---|---|
<T : Any?> |
the entry's |
| Returns | |
|---|---|
T |
A new instance of this entry's |
toRoute
fun <T : Any?> NavBackStackEntry.toRoute(route: KClass<*>): T
Returns route as an object of type T
Extrapolates arguments from NavBackStackEntry.arguments and recreates object T
| Parameters | |
|---|---|
route: KClass<*> |
the entry's |
| Returns | |
|---|---|
T |
A new instance of this entry's |
LocalOwnersProvider
@Composable
fun NavBackStackEntry.LocalOwnersProvider(
saveableStateHolder: SaveableStateHolder,
content: @Composable () -> Unit
): Unit
Provides this as LocalViewModelStoreOwner, LocalLifecycleOwner and LocalSavedStateRegistryOwner to the content and saves the content's saveable states with the given saveableStateHolder.
| Parameters | |
|---|---|
saveableStateHolder: SaveableStateHolder |
The |
content: @Composable () -> Unit |
The content |