# NavGraphNavigator

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

*** ** * ** ***


```
@Navigator.Name(value = "navigation")
public class NavGraphNavigator extends Navigator<@NonNull NavGraph>
```

<br />

|---|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object.html) |||
| ↳ | [androidx.navigation.Navigator](https://developer.android.com/reference/androidx/navigation/Navigator)\<@[NonNull](https://developer.android.com/reference/androidx/annotation/NonNull) [NavGraph](https://developer.android.com/reference/androidx/navigation/NavGraph)\> ||
|   | ↳ | [androidx.navigation.NavGraphNavigator](https://developer.android.com/reference/androidx/navigation/NavGraphNavigator) |

Known direct subclasses [DynamicGraphNavigator](https://developer.android.com/reference/androidx/navigation/dynamicfeatures/DynamicGraphNavigator)

|---|---|
| `https://developer.android.com/reference/androidx/navigation/dynamicfeatures/DynamicGraphNavigator` | Navigator for graphs in dynamic feature modules. |

*** ** * ** ***

A Navigator built specifically for `https://developer.android.com/reference/androidx/navigation/NavGraph` elements. Handles navigating to the correct destination when the NavGraph is the target of navigation actions.

Construct a Navigator capable of routing incoming navigation requests to the proper destination within a `https://developer.android.com/reference/androidx/navigation/NavGraph`.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/navigation/NavGraphNavigator#NavGraphNavigator(androidx.navigation.NavigatorProvider)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavigatorProvider navigatorProvider)` |

| ### Public methods |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavGraph` | `https://developer.android.com/reference/androidx/navigation/NavGraphNavigator#createDestination()()` Creates a new `https://developer.android.com/reference/androidx/navigation/NavGraph` 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/NavGraphNavigator#getBackStack()()` Gets the backstack of `https://developer.android.com/reference/androidx/navigation/NavBackStackEntry` associated with this Navigator |
| `void` | `https://developer.android.com/reference/androidx/navigation/NavGraphNavigator#navigate(kotlin.collections.List,androidx.navigation.NavOptions,androidx.navigation.Navigator.Extras)( @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> entries, https://developer.android.com/reference/androidx/navigation/NavOptions navOptions, https://developer.android.com/reference/androidx/navigation/Navigator.Extras navigatorExtras )` |

### Inherited methods

From [androidx.navigation.Navigator](https://developer.android.com/reference/androidx/navigation/Navigator) `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavigatorState` `https://developer.android.com/reference/androidx/navigation/Navigator#getState()()`

The state of the Navigator is the communication conduit between the Navigator and the `https://developer.android.com/reference/androidx/navigation/NavController` that has called `https://developer.android.com/reference/androidx/navigation/Navigator#onAttach(androidx.navigation.NavigatorState)`.
`final boolean` `https://developer.android.com/reference/androidx/navigation/Navigator#isAttached()()`

Whether this Navigator is actively being used by a `https://developer.android.com/reference/androidx/navigation/NavController`.
`https://developer.android.com/reference/androidx/navigation/NavDestination` `https://developer.android.com/reference/androidx/navigation/Navigator#navigate(androidx.navigation.NavDestination,androidx.savedstate.SavedState,androidx.navigation.NavOptions,androidx.navigation.Navigator.Extras)(
@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavGraph destination,
https://developer.android.com/reference/androidx/savedstate/SavedState args,
https://developer.android.com/reference/androidx/navigation/NavOptions navOptions,
https://developer.android.com/reference/androidx/navigation/Navigator.Extras navigatorExtras
)`

Navigate to a destination.
`void` `@https://developer.android.com/reference/androidx/annotation/CallSuper
https://developer.android.com/reference/androidx/navigation/Navigator#onAttach(androidx.navigation.NavigatorState)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavigatorState state)`

Indicator that this Navigator is actively being used by a `https://developer.android.com/reference/androidx/navigation/NavController`.
`void` `https://developer.android.com/reference/androidx/navigation/Navigator#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/Navigator#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/navigation/Navigator#onRestoreState(androidx.savedstate.SavedState)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/savedstate/SavedState savedState)`

Restore any state previously saved in `https://developer.android.com/reference/androidx/navigation/Navigator#onSaveState()`.
`https://developer.android.com/reference/androidx/savedstate/SavedState` `https://developer.android.com/reference/androidx/navigation/Navigator#onSaveState()()`

Called to ask for a `https://developer.android.com/reference/androidx/savedstate/SavedState` representing the Navigator's state.
`boolean` `https://developer.android.com/reference/androidx/navigation/Navigator#popBackStack()()`

Attempt to pop this navigator's back stack, performing the appropriate navigation.
`void` `https://developer.android.com/reference/androidx/navigation/Navigator#popBackStack(androidx.navigation.NavBackStackEntry,kotlin.Boolean)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavBackStackEntry popUpTo, boolean savedState)`

Attempt to pop this navigator's back stack, performing the appropriate navigation.

## Public constructors

### NavGraphNavigator

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

```
public NavGraphNavigator(@NonNull NavigatorProvider navigatorProvider)
```

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavigatorProvider navigatorProvider` | NavigatorProvider used to retrieve the correct `https://developer.android.com/reference/androidx/navigation/Navigator` to navigate to the start destination |

## Public methods

### createDestination

```
public @NonNull NavGraph createDestination()
```

Creates a new `https://developer.android.com/reference/androidx/navigation/NavGraph` associated with this navigator.

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigation/NavGraph` | The created `https://developer.android.com/reference/androidx/navigation/NavGraph`. |

### getBackStack

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

```
public final @NonNull StateFlow<@NonNull List<@NonNull NavBackStackEntry>> getBackStack()
```

Gets the backstack of `https://developer.android.com/reference/androidx/navigation/NavBackStackEntry` associated with this Navigator

### navigate

```
public void navigate(
    @NonNull List<@NonNull NavBackStackEntry> entries,
    NavOptions navOptions,
    Navigator.Extras navigatorExtras
)
```

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if given destination is not a child of the current navgraph |