NavGraphNavigator


@Navigator.Name(value = "navigation")
public class NavGraphNavigator extends Navigator

Known direct subclasses
DynamicGraphNavigator

Navigator for graphs in dynamic feature modules.


A Navigator built specifically for 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 NavGraph.

Summary

Public constructors

Public methods

@NonNull NavGraph

Creates a new NavGraph associated with this navigator.

final @NonNull StateFlow<@NonNull List<@NonNull NavBackStackEntry>>

Gets the backstack of NavBackStackEntry associated with this Navigator

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

Inherited methods

From androidx.navigation.Navigator
final @NonNull NavigatorState

The state of the Navigator is the communication conduit between the Navigator and the NavController that has called onAttach.

final boolean

Whether this Navigator is actively being used by a NavController.

NavDestination
navigate(
    @NonNull NavGraph destination,
    Bundle args,
    NavOptions navOptions,
    Navigator.Extras navigatorExtras
)

Navigate to a destination.

void

Indicator that this Navigator is actively being used by a NavController.

void

Informational callback indicating that the given backStackEntry has been affected by a NavOptions.shouldLaunchSingleTop operation.

void

Restore any state previously saved in onSaveState.

Bundle

Called to ask for a Bundle representing the Navigator's state.

boolean

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

void
popBackStack(@NonNull NavBackStackEntry popUpTo, boolean savedState)

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

Public constructors

Added in 1.0.0
public NavGraphNavigator(@NonNull NavigatorProvider navigatorProvider)
Parameters
@NonNull NavigatorProvider navigatorProvider

NavigatorProvider used to retrieve the correct Navigator to navigate to the start destination

Public methods

createDestination

Added in 2.9.0-alpha03
public @NonNull NavGraph createDestination()

Creates a new NavGraph associated with this navigator.

Returns
@NonNull NavGraph

The created NavGraph.

getBackStack

Added in 2.6.0
public final @NonNull StateFlow<@NonNull List<@NonNull NavBackStackEntry>> getBackStack()

Gets the backstack of NavBackStackEntry associated with this Navigator

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

if given destination is not a child of the current navgraph