# TestNavigatorState

Artifact: [androidx.navigation:navigation-testing](https://developer.android.com/jetpack/androidx/releases/navigation) [View Source](https://cs.android.com/search?q=file:androidx/navigation/testing/TestNavigatorState.+class:androidx.navigation.testing.TestNavigatorState) Added in [2.4.0](https://developer.android.com/jetpack/androidx/releases/navigation#2.4.0)

*** ** * ** ***


```
public final class TestNavigatorState extends NavigatorState
```

<br />

|---|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object.html) |||
| ↳ | [androidx.navigation.NavigatorState](https://developer.android.com/reference/androidx/navigation/NavigatorState) ||
|   | ↳ | [androidx.navigation.testing.TestNavigatorState](https://developer.android.com/reference/androidx/navigation/testing/TestNavigatorState) |

*** ** * ** ***

An implementation of `https://developer.android.com/reference/androidx/navigation/NavigatorState` that allows testing a `https://developer.android.com/reference/androidx/navigation/Navigator` in isolation (i.e., without requiring a `https://developer.android.com/reference/androidx/navigation/NavController`).

The `https://developer.android.com/reference/androidx/lifecycle/Lifecycle` of all `https://developer.android.com/reference/androidx/navigation/NavBackStackEntry` instances added to this TestNavigatorState will be updated as they are added and removed from the state. This work is kicked off on the `https://developer.android.com/reference/androidx/navigation/testing/TestNavigatorState#(kotlinx.coroutines.CoroutineDispatcher)`.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/navigation/testing/TestNavigatorState#TestNavigatorState(kotlinx.coroutines.CoroutineDispatcher)(@https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-dispatcher/index.html coroutineDispatcher)` |
| `https://developer.android.com/reference/androidx/navigation/testing/TestNavigatorState#TestNavigatorState(android.content.Context,kotlinx.coroutines.CoroutineDispatcher)( https://developer.android.com/reference/android/content/Context.html context, @https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-dispatcher/index.html coroutineDispatcher )` |

| ### Public methods |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavBackStackEntry` | `https://developer.android.com/reference/androidx/navigation/testing/TestNavigatorState#createBackStackEntry(androidx.navigation.NavDestination,android.os.Bundle)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavDestination destination, https://developer.android.com/reference/android/os/Bundle.html arguments )` Create a new `https://developer.android.com/reference/androidx/navigation/NavBackStackEntry` from a given `https://developer.android.com/reference/androidx/navigation/NavigatorState#createBackStackEntry(androidx.navigation.NavDestination,androidx.savedstate.SavedState)` and `https://developer.android.com/reference/androidx/navigation/NavigatorState#createBackStackEntry(androidx.navigation.NavDestination,androidx.savedstate.SavedState)`. |
| `void` | `https://developer.android.com/reference/androidx/navigation/testing/TestNavigatorState#markTransitionComplete(androidx.navigation.NavBackStackEntry)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavBackStackEntry entry)` This removes the given `https://developer.android.com/reference/androidx/navigation/NavBackStackEntry` from the `https://developer.android.com/reference/androidx/navigation/NavigatorState#transitionsInProgress()`. |
| `void` | `https://developer.android.com/reference/androidx/navigation/testing/TestNavigatorState#markTransitionComplete(androidx.navigation.NavBackStackEntry)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavBackStackEntry entry)` This removes the given `https://developer.android.com/reference/androidx/navigation/NavBackStackEntry` from the `https://developer.android.com/reference/androidx/navigation/NavigatorState#transitionsInProgress()`. |
| `void` | `https://developer.android.com/reference/androidx/navigation/testing/TestNavigatorState#pop(androidx.navigation.NavBackStackEntry,kotlin.Boolean)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavBackStackEntry popUpTo, boolean saveState)` Pop all destinations up to and including `https://developer.android.com/reference/androidx/navigation/NavigatorState#pop(androidx.navigation.NavBackStackEntry,kotlin.Boolean)`. |
| `void` | `https://developer.android.com/reference/androidx/navigation/testing/TestNavigatorState#pop(androidx.navigation.NavBackStackEntry,kotlin.Boolean)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavBackStackEntry popUpTo, boolean saveState)` Pop all destinations up to and including `https://developer.android.com/reference/androidx/navigation/NavigatorState#pop(androidx.navigation.NavBackStackEntry,kotlin.Boolean)`. |
| `void` | `https://developer.android.com/reference/androidx/navigation/testing/TestNavigatorState#popWithTransition(androidx.navigation.NavBackStackEntry,kotlin.Boolean)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavBackStackEntry popUpTo, boolean saveState)` Pops all destinations up to and including `https://developer.android.com/reference/androidx/navigation/NavigatorState#popWithTransition(androidx.navigation.NavBackStackEntry,kotlin.Boolean)`. |
| `void` | `https://developer.android.com/reference/androidx/navigation/testing/TestNavigatorState#popWithTransition(androidx.navigation.NavBackStackEntry,kotlin.Boolean)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavBackStackEntry popUpTo, boolean saveState)` Pops all destinations up to and including `https://developer.android.com/reference/androidx/navigation/NavigatorState#popWithTransition(androidx.navigation.NavBackStackEntry,kotlin.Boolean)`. |
| `void` | `https://developer.android.com/reference/androidx/navigation/testing/TestNavigatorState#prepareForTransition(androidx.navigation.NavBackStackEntry)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavBackStackEntry entry)` This prepares the given `https://developer.android.com/reference/androidx/navigation/NavBackStackEntry` for transition. |
| `void` | `https://developer.android.com/reference/androidx/navigation/testing/TestNavigatorState#prepareForTransition(androidx.navigation.NavBackStackEntry)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavBackStackEntry entry)` This prepares the given `https://developer.android.com/reference/androidx/navigation/NavBackStackEntry` for transition. |
| `void` | `https://developer.android.com/reference/androidx/navigation/testing/TestNavigatorState#push(androidx.navigation.NavBackStackEntry)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavBackStackEntry backStackEntry)` Adds the given `https://developer.android.com/reference/androidx/navigation/NavigatorState#push(androidx.navigation.NavBackStackEntry)` to the `https://developer.android.com/reference/androidx/navigation/NavigatorState#backStack()`. |
| `void` | `https://developer.android.com/reference/androidx/navigation/testing/TestNavigatorState#push(androidx.navigation.NavBackStackEntry)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavBackStackEntry backStackEntry)` Adds the given `https://developer.android.com/reference/androidx/navigation/NavigatorState#push(androidx.navigation.NavBackStackEntry)` to the `https://developer.android.com/reference/androidx/navigation/NavigatorState#backStack()`. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavBackStackEntry` | `https://developer.android.com/reference/androidx/navigation/testing/TestNavigatorState#restoreBackStackEntry(androidx.navigation.NavBackStackEntry)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavBackStackEntry previouslySavedEntry)` Restore a previously saved `https://developer.android.com/reference/androidx/navigation/NavBackStackEntry`. |

### Inherited methods

From [androidx.navigation.NavigatorState](https://developer.android.com/reference/androidx/navigation/NavigatorState) `final @https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-state-flow/index.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavBackStackEntry>>` `https://developer.android.com/reference/androidx/navigation/NavigatorState#getBackStack()()`

While the `https://developer.android.com/reference/androidx/navigation/NavController` is responsible for the combined back stack across all Navigators, this back stack is specifically the set of destinations associated with this Navigator.
`final @https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-state-flow/index.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavBackStackEntry>>` `https://developer.android.com/reference/androidx/navigation/NavigatorState#getBackStack()()`

While the `https://developer.android.com/reference/androidx/navigation/NavController` is responsible for the combined back stack across all Navigators, this back stack is specifically the set of destinations associated with this Navigator.
`final @https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-state-flow/index.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavBackStackEntry>>` `https://developer.android.com/reference/androidx/navigation/NavigatorState#getBackStack()()`

While the `https://developer.android.com/reference/androidx/navigation/NavController` is responsible for the combined back stack across all Navigators, this back stack is specifically the set of destinations associated with this Navigator.
`final @https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-state-flow/index.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/Set.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavBackStackEntry>>` `https://developer.android.com/reference/androidx/navigation/NavigatorState#getTransitionsInProgress()()`

This is the set of currently running transitions.
`final @https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-state-flow/index.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/Set.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavBackStackEntry>>` `https://developer.android.com/reference/androidx/navigation/NavigatorState#getTransitionsInProgress()()`

This is the set of currently running transitions.
`final @https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-state-flow/index.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/Set.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavBackStackEntry>>` `https://developer.android.com/reference/androidx/navigation/NavigatorState#getTransitionsInProgress()()`

This is the set of currently running transitions.
`void` `https://developer.android.com/reference/androidx/navigation/NavigatorState#markTransitionComplete(androidx.navigation.NavBackStackEntry)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavBackStackEntry entry)`

This removes the given `https://developer.android.com/reference/androidx/navigation/NavBackStackEntry` from the `https://developer.android.com/reference/androidx/navigation/NavigatorState#transitionsInProgress()`.
`void` `@https://developer.android.com/reference/androidx/annotation/CallSuper
https://developer.android.com/reference/androidx/navigation/NavigatorState#onLaunchSingleTop(androidx.navigation.NavBackStackEntry)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavBackStackEntry backStackEntry)`

Informational callback indicating that the given `https://developer.android.com/reference/androidx/navigation/NavigatorState#onLaunchSingleTop(androidx.navigation.NavBackStackEntry)` has been affected by a `https://developer.android.com/reference/androidx/navigation/NavOptions#shouldLaunchSingleTop()` operation.
`void` `@https://developer.android.com/reference/androidx/annotation/CallSuper
https://developer.android.com/reference/androidx/navigation/NavigatorState#onLaunchSingleTop(androidx.navigation.NavBackStackEntry)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavBackStackEntry backStackEntry)`

Informational callback indicating that the given `https://developer.android.com/reference/androidx/navigation/NavigatorState#onLaunchSingleTop(androidx.navigation.NavBackStackEntry)` has been affected by a `https://developer.android.com/reference/androidx/navigation/NavOptions#shouldLaunchSingleTop()` operation.
`void` `@https://developer.android.com/reference/androidx/annotation/CallSuper
https://developer.android.com/reference/androidx/navigation/NavigatorState#onLaunchSingleTop(androidx.navigation.NavBackStackEntry)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavBackStackEntry backStackEntry)`

Informational callback indicating that the given `https://developer.android.com/reference/androidx/navigation/NavigatorState#onLaunchSingleTop(androidx.navigation.NavBackStackEntry)` has been affected by a `https://developer.android.com/reference/androidx/navigation/NavOptions#shouldLaunchSingleTop()` operation.
`void` `@https://developer.android.com/reference/androidx/annotation/CallSuper
https://developer.android.com/reference/androidx/navigation/NavigatorState#onLaunchSingleTopWithTransition(androidx.navigation.NavBackStackEntry)(
@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavBackStackEntry backStackEntry
)`

Informational callback indicating that the given `https://developer.android.com/reference/androidx/navigation/NavigatorState#onLaunchSingleTopWithTransition(androidx.navigation.NavBackStackEntry)` has been affected by a `https://developer.android.com/reference/androidx/navigation/NavOptions#shouldLaunchSingleTop()` operation.
`void` `@https://developer.android.com/reference/androidx/annotation/CallSuper
https://developer.android.com/reference/androidx/navigation/NavigatorState#onLaunchSingleTopWithTransition(androidx.navigation.NavBackStackEntry)(
@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavBackStackEntry backStackEntry
)`

Informational callback indicating that the given `https://developer.android.com/reference/androidx/navigation/NavigatorState#onLaunchSingleTopWithTransition(androidx.navigation.NavBackStackEntry)` has been affected by a `https://developer.android.com/reference/androidx/navigation/NavOptions#shouldLaunchSingleTop()` operation.
`void` `@https://developer.android.com/reference/androidx/annotation/CallSuper
https://developer.android.com/reference/androidx/navigation/NavigatorState#onLaunchSingleTopWithTransition(androidx.navigation.NavBackStackEntry)(
@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavBackStackEntry backStackEntry
)`

Informational callback indicating that the given `https://developer.android.com/reference/androidx/navigation/NavigatorState#onLaunchSingleTopWithTransition(androidx.navigation.NavBackStackEntry)` has been affected by a `https://developer.android.com/reference/androidx/navigation/NavOptions#shouldLaunchSingleTop()` operation.
`void` `https://developer.android.com/reference/androidx/navigation/NavigatorState#pop(androidx.navigation.NavBackStackEntry,kotlin.Boolean)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavBackStackEntry popUpTo, boolean saveState)`

Pop all destinations up to and including `https://developer.android.com/reference/androidx/navigation/NavigatorState#pop(androidx.navigation.NavBackStackEntry,kotlin.Boolean)`.
`void` `https://developer.android.com/reference/androidx/navigation/NavigatorState#popWithTransition(androidx.navigation.NavBackStackEntry,kotlin.Boolean)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavBackStackEntry popUpTo, boolean saveState)`

Pops all destinations up to and including `https://developer.android.com/reference/androidx/navigation/NavigatorState#popWithTransition(androidx.navigation.NavBackStackEntry,kotlin.Boolean)`.
`void` `@https://developer.android.com/reference/androidx/annotation/CallSuper
https://developer.android.com/reference/androidx/navigation/NavigatorState#prepareForTransition(androidx.navigation.NavBackStackEntry)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavBackStackEntry entry)`

This prepares the given `https://developer.android.com/reference/androidx/navigation/NavBackStackEntry` for transition.
`void` `https://developer.android.com/reference/androidx/navigation/NavigatorState#push(androidx.navigation.NavBackStackEntry)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavBackStackEntry backStackEntry)`

Adds the given `https://developer.android.com/reference/androidx/navigation/NavigatorState#push(androidx.navigation.NavBackStackEntry)` to the `https://developer.android.com/reference/androidx/navigation/NavigatorState#backStack()`.
`void` `https://developer.android.com/reference/androidx/navigation/NavigatorState#pushWithTransition(androidx.navigation.NavBackStackEntry)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavBackStackEntry backStackEntry)`

Adds the given `https://developer.android.com/reference/androidx/navigation/NavigatorState#pushWithTransition(androidx.navigation.NavBackStackEntry)` to the `https://developer.android.com/reference/androidx/navigation/NavigatorState#backStack()`.
`void` `https://developer.android.com/reference/androidx/navigation/NavigatorState#pushWithTransition(androidx.navigation.NavBackStackEntry)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavBackStackEntry backStackEntry)`

Adds the given `https://developer.android.com/reference/androidx/navigation/NavigatorState#pushWithTransition(androidx.navigation.NavBackStackEntry)` to the `https://developer.android.com/reference/androidx/navigation/NavigatorState#backStack()`.
`void` `https://developer.android.com/reference/androidx/navigation/NavigatorState#pushWithTransition(androidx.navigation.NavBackStackEntry)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavBackStackEntry backStackEntry)`

Adds the given `https://developer.android.com/reference/androidx/navigation/NavigatorState#pushWithTransition(androidx.navigation.NavBackStackEntry)` to the `https://developer.android.com/reference/androidx/navigation/NavigatorState#backStack()`.

## Public constructors

### TestNavigatorState

Added in [2.10.2](https://developer.android.com/jetpack/androidx/releases/navigation#2.10.2)

```
public TestNavigatorState(@NonNull CoroutineDispatcher coroutineDispatcher)
```

### TestNavigatorState

Added in [2.4.0](https://developer.android.com/jetpack/androidx/releases/navigation#2.4.0)

```
public TestNavigatorState(
    Context context,
    @NonNull CoroutineDispatcher coroutineDispatcher
)
```

## Public methods

### createBackStackEntry

Added in [2.4.0](https://developer.android.com/jetpack/androidx/releases/navigation#2.4.0)

```
public @NonNull NavBackStackEntry createBackStackEntry(
    @NonNull NavDestination destination,
    Bundle arguments
)
```

Create a new `https://developer.android.com/reference/androidx/navigation/NavBackStackEntry` from a given `https://developer.android.com/reference/androidx/navigation/NavigatorState#createBackStackEntry(androidx.navigation.NavDestination,androidx.savedstate.SavedState)` and `https://developer.android.com/reference/androidx/navigation/NavigatorState#createBackStackEntry(androidx.navigation.NavDestination,androidx.savedstate.SavedState)`.

### markTransitionComplete

```
public void markTransitionComplete(@NonNull NavBackStackEntry entry)
```

This removes the given `https://developer.android.com/reference/androidx/navigation/NavBackStackEntry` from the `https://developer.android.com/reference/androidx/navigation/NavigatorState#transitionsInProgress()`. This should be called in conjunction with `https://developer.android.com/reference/androidx/navigation/NavigatorState#pushWithTransition(androidx.navigation.NavBackStackEntry)` and `https://developer.android.com/reference/androidx/navigation/NavigatorState#popWithTransition(androidx.navigation.NavBackStackEntry,kotlin.Boolean)` as those call are responsible for adding entries to `https://developer.android.com/reference/androidx/navigation/NavigatorState#transitionsInProgress()`.

This should also always be called in conjunction with `https://developer.android.com/reference/androidx/navigation/NavigatorState#prepareForTransition(androidx.navigation.NavBackStackEntry)` to ensure all `https://developer.android.com/reference/androidx/navigation/NavBackStackEntry` settle into the proper state.

Failing to call this method could result in entries being prevented from reaching their final `https://developer.android.com/reference/androidx/lifecycle/Lifecycle.State`}.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/navigation/NavigatorState#pushWithTransition(androidx.navigation.NavBackStackEntry)` |   |
| `https://developer.android.com/reference/androidx/navigation/NavigatorState#popWithTransition(androidx.navigation.NavBackStackEntry,kotlin.Boolean)` |   |

### markTransitionComplete

```
public void markTransitionComplete(@NonNull NavBackStackEntry entry)
```

This removes the given `https://developer.android.com/reference/androidx/navigation/NavBackStackEntry` from the `https://developer.android.com/reference/androidx/navigation/NavigatorState#transitionsInProgress()`. This should be called in conjunction with `https://developer.android.com/reference/androidx/navigation/NavigatorState#pushWithTransition(androidx.navigation.NavBackStackEntry)` and `https://developer.android.com/reference/androidx/navigation/NavigatorState#popWithTransition(androidx.navigation.NavBackStackEntry,kotlin.Boolean)` as those call are responsible for adding entries to `https://developer.android.com/reference/androidx/navigation/NavigatorState#transitionsInProgress()`.

This should also always be called in conjunction with `https://developer.android.com/reference/androidx/navigation/NavigatorState#prepareForTransition(androidx.navigation.NavBackStackEntry)` to ensure all `https://developer.android.com/reference/androidx/navigation/NavBackStackEntry` settle into the proper state.

Failing to call this method could result in entries being prevented from reaching their final `https://developer.android.com/reference/androidx/lifecycle/Lifecycle.State`}.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/navigation/NavigatorState#pushWithTransition(androidx.navigation.NavBackStackEntry)` |   |
| `https://developer.android.com/reference/androidx/navigation/NavigatorState#popWithTransition(androidx.navigation.NavBackStackEntry,kotlin.Boolean)` |   |

### pop

```
public void pop(@NonNull NavBackStackEntry popUpTo, boolean saveState)
```

Pop all destinations up to and including `https://developer.android.com/reference/androidx/navigation/NavigatorState#pop(androidx.navigation.NavBackStackEntry,kotlin.Boolean)`. This will remove those destinations from the `https://developer.android.com/reference/androidx/navigation/NavigatorState#backStack()`, saving their state if `https://developer.android.com/reference/androidx/navigation/NavigatorState#pop(androidx.navigation.NavBackStackEntry,kotlin.Boolean)` is `true`.

### pop

```
public void pop(@NonNull NavBackStackEntry popUpTo, boolean saveState)
```

Pop all destinations up to and including `https://developer.android.com/reference/androidx/navigation/NavigatorState#pop(androidx.navigation.NavBackStackEntry,kotlin.Boolean)`. This will remove those destinations from the `https://developer.android.com/reference/androidx/navigation/NavigatorState#backStack()`, saving their state if `https://developer.android.com/reference/androidx/navigation/NavigatorState#pop(androidx.navigation.NavBackStackEntry,kotlin.Boolean)` is `true`.

### popWithTransition

```
public void popWithTransition(@NonNull NavBackStackEntry popUpTo, boolean saveState)
```

Pops all destinations up to and including `https://developer.android.com/reference/androidx/navigation/NavigatorState#popWithTransition(androidx.navigation.NavBackStackEntry,kotlin.Boolean)`. This also adds the given and incoming entry to the `https://developer.android.com/reference/androidx/navigation/NavigatorState#transitionsInProgress()`. Added entries have their `https://developer.android.com/reference/androidx/lifecycle/Lifecycle` held at `https://developer.android.com/reference/androidx/lifecycle/Lifecycle.State#CREATED` until an entry is passed into the `https://developer.android.com/reference/androidx/navigation/NavigatorState#markTransitionComplete(androidx.navigation.NavBackStackEntry)` callback, when they are allowed to go to `https://developer.android.com/reference/androidx/lifecycle/Lifecycle.State#DESTROYED` and have their state cleared.

This will remove those destinations from the `https://developer.android.com/reference/androidx/navigation/NavigatorState#backStack()`, saving their state if `https://developer.android.com/reference/androidx/navigation/NavigatorState#popWithTransition(androidx.navigation.NavBackStackEntry,kotlin.Boolean)` is `true`.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/navigation/NavigatorState#transitionsInProgress()` |   |
| `https://developer.android.com/reference/androidx/navigation/NavigatorState#markTransitionComplete(androidx.navigation.NavBackStackEntry)` |   |
| `https://developer.android.com/reference/androidx/navigation/NavigatorState#pushWithTransition(androidx.navigation.NavBackStackEntry)` |   |

### popWithTransition

```
public void popWithTransition(@NonNull NavBackStackEntry popUpTo, boolean saveState)
```

Pops all destinations up to and including `https://developer.android.com/reference/androidx/navigation/NavigatorState#popWithTransition(androidx.navigation.NavBackStackEntry,kotlin.Boolean)`. This also adds the given and incoming entry to the `https://developer.android.com/reference/androidx/navigation/NavigatorState#transitionsInProgress()`. Added entries have their `https://developer.android.com/reference/androidx/lifecycle/Lifecycle` held at `https://developer.android.com/reference/androidx/lifecycle/Lifecycle.State#CREATED` until an entry is passed into the `https://developer.android.com/reference/androidx/navigation/NavigatorState#markTransitionComplete(androidx.navigation.NavBackStackEntry)` callback, when they are allowed to go to `https://developer.android.com/reference/androidx/lifecycle/Lifecycle.State#DESTROYED` and have their state cleared.

This will remove those destinations from the `https://developer.android.com/reference/androidx/navigation/NavigatorState#backStack()`, saving their state if `https://developer.android.com/reference/androidx/navigation/NavigatorState#popWithTransition(androidx.navigation.NavBackStackEntry,kotlin.Boolean)` is `true`.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/navigation/NavigatorState#transitionsInProgress()` |   |
| `https://developer.android.com/reference/androidx/navigation/NavigatorState#markTransitionComplete(androidx.navigation.NavBackStackEntry)` |   |
| `https://developer.android.com/reference/androidx/navigation/NavigatorState#pushWithTransition(androidx.navigation.NavBackStackEntry)` |   |

### prepareForTransition

```
public void prepareForTransition(@NonNull NavBackStackEntry entry)
```

This prepares the given `https://developer.android.com/reference/androidx/navigation/NavBackStackEntry` for transition. This should be called in conjunction with `https://developer.android.com/reference/androidx/navigation/NavigatorState#markTransitionComplete(androidx.navigation.NavBackStackEntry)` as that is responsible for settling the `https://developer.android.com/reference/androidx/navigation/NavBackStackEntry` into its final state.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/navigation/NavigatorState#markTransitionComplete(androidx.navigation.NavBackStackEntry)` |   |

### prepareForTransition

```
public void prepareForTransition(@NonNull NavBackStackEntry entry)
```

This prepares the given `https://developer.android.com/reference/androidx/navigation/NavBackStackEntry` for transition. This should be called in conjunction with `https://developer.android.com/reference/androidx/navigation/NavigatorState#markTransitionComplete(androidx.navigation.NavBackStackEntry)` as that is responsible for settling the `https://developer.android.com/reference/androidx/navigation/NavBackStackEntry` into its final state.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/navigation/NavigatorState#markTransitionComplete(androidx.navigation.NavBackStackEntry)` |   |

### push

```
public void push(@NonNull NavBackStackEntry backStackEntry)
```

Adds the given `https://developer.android.com/reference/androidx/navigation/NavigatorState#push(androidx.navigation.NavBackStackEntry)` to the `https://developer.android.com/reference/androidx/navigation/NavigatorState#backStack()`.

### push

```
public void push(@NonNull NavBackStackEntry backStackEntry)
```

Adds the given `https://developer.android.com/reference/androidx/navigation/NavigatorState#push(androidx.navigation.NavBackStackEntry)` to the `https://developer.android.com/reference/androidx/navigation/NavigatorState#backStack()`.

### restoreBackStackEntry

Added in [2.4.0](https://developer.android.com/jetpack/androidx/releases/navigation#2.4.0)

```
public final @NonNull NavBackStackEntry restoreBackStackEntry(@NonNull NavBackStackEntry previouslySavedEntry)
```

Restore a previously saved `https://developer.android.com/reference/androidx/navigation/NavBackStackEntry`. You must have previously called `https://developer.android.com/reference/androidx/navigation/NavigatorState#pop(androidx.navigation.NavBackStackEntry,kotlin.Boolean)` with `https://developer.android.com/reference/androidx/navigation/testing/TestNavigatorState#restoreBackStackEntry(androidx.navigation.NavBackStackEntry)` and `true`.