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
equals(other: Any?)
android
open Int
android
open String
android

Public properties

Bundle?

The arguments used for this entry.

android
open CreationExtras

Returns the default CreationExtras that should be passed into ViewModelProvider.Factory.create when no overriding CreationExtras were passed to the ViewModelProvider constructors.

android
open ViewModelProvider.Factory

Returns the default ViewModelProvider.Factory that should be used when no custom Factory is provided to the ViewModelProvider constructors.

android
NavDestination

The destination associated with this entry

android
String

The unique ID that serves as the identity of this entry

android
open Lifecycle

{@inheritDoc}

android
SavedStateHandle

The SavedStateHandle for this entry.

android
open SavedStateRegistry

The SavedStateRegistry owned by this SavedStateRegistryOwner

android
open ViewModelStore

The owned ViewModelStore

android

Extension functions

inline T

Returns route as an object of type T

android
T
<T : Any?> NavBackStackEntry.toRoute(route: KClass<*>)

Returns route as an object of type T

android

Public functions

equals

open operator fun equals(other: Any?): Boolean

hashCode

open fun hashCode(): Int

toString

open fun toString(): String

Public properties

arguments

val argumentsBundle?

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
Bundle?

The arguments used when this entry was created

defaultViewModelCreationExtras

open val defaultViewModelCreationExtrasCreationExtras

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 defaultViewModelProviderFactoryViewModelProvider.Factory

Returns the default ViewModelProvider.Factory that should be used when no custom Factory is provided to the ViewModelProvider constructors.

destination

val destinationNavDestination

The destination associated with this entry

Returns
NavDestination

The destination that is currently visible to users

id

val idString

The unique ID that serves as the identity of this entry

Returns
String

the unique ID of this entry

lifecycle

open val lifecycleLifecycle

{@inheritDoc}

If the androidx.navigation.NavHost has not called androidx.navigation.NavHostController.setLifecycleOwner, the Lifecycle will be capped at Lifecycle.State.CREATED.

savedStateHandle

val savedStateHandleSavedStateHandle

The SavedStateHandle for this entry.

savedStateRegistry

open val savedStateRegistrySavedStateRegistry

The SavedStateRegistry owned by this SavedStateRegistryOwner

viewModelStore

open val viewModelStoreViewModelStore

The owned ViewModelStore

Extension functions

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 NavDestination.route as a KClass

Returns
T

A new instance of this entry's NavDestination.route as an object of type T

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 NavDestination.route as a KClass

Returns
T

A new instance of this entry's NavDestination.route as an object of type T