@Navigator.Name(value = "navigation")
class DynamicGraphNavigator : NavGraphNavigator


Navigator for graphs in dynamic feature modules.

This class handles navigating to a progress destination when the installation of a dynamic feature module is required. By default, the progress destination set by installDefaultProgressDestination will be used, but this can be overridden by setting the app:progressDestinationId attribute in your navigation XML file.

Summary

Nested types

The NavGraph for dynamic features.

Public constructors

DynamicGraphNavigator(
    navigatorProvider: NavigatorProvider,
    installManager: DynamicInstallManager
)

Public functions

open DynamicGraphNavigator.DynamicNavGraph

Create a destination for the DynamicNavGraph.

Unit
installDefaultProgressDestination(
    progressDestinationSupplier: () -> NavDestination
)

Installs the default progress destination to this graph via a lambda.

open Unit
navigate(
    entries: List<NavBackStackEntry>,
    navOptions: NavOptions?,
    navigatorExtras: Navigator.Extras?
)

Navigate to a destination.

open Unit
onRestoreState(savedState: Bundle)
open Bundle?

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

Inherited functions

From androidx.navigation.Navigator
open NavDestination?
navigate(
    destination: NavGraph,
    args: SavedState?,
    navOptions: NavOptions?,
    navigatorExtras: Navigator.Extras?
)

Navigate to a destination.

open Unit

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

open Unit

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

open Unit

Restore any state previously saved in onSaveState.

open Boolean

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

open Unit
popBackStack(popUpTo: NavBackStackEntry, savedState: Boolean)

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

Inherited properties

From androidx.navigation.NavGraphNavigator
StateFlow<List<NavBackStackEntry>>

Gets the backstack of NavBackStackEntry associated with this Navigator

From androidx.navigation.Navigator
Boolean

Whether this Navigator is actively being used by a NavController.

NavigatorState

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

Public constructors

DynamicGraphNavigator

Added in 2.3.0
DynamicGraphNavigator(
    navigatorProvider: NavigatorProvider,
    installManager: DynamicInstallManager
)

Public functions

createDestination

Added in 2.3.0
open fun createDestination(): DynamicGraphNavigator.DynamicNavGraph

Create a destination for the DynamicNavGraph.

Returns
DynamicGraphNavigator.DynamicNavGraph

The created graph.

installDefaultProgressDestination

fun installDefaultProgressDestination(
    progressDestinationSupplier: () -> NavDestination
): Unit

Installs the default progress destination to this graph via a lambda. This supplies a NavDestination to use when the actual destination is not installed at navigation time.

This must be called before you call androidx.navigation.NavController.setGraph to ensure that all DynamicNavGraph instances have the correct progress destination installed in onRestoreState.

Parameters
progressDestinationSupplier: () -> NavDestination

The default progress destination supplier.

open fun navigate(
    entries: List<NavBackStackEntry>,
    navOptions: NavOptions?,
    navigatorExtras: Navigator.Extras?
): Unit

Navigate to a destination.

In case the destination module is installed the navigation will trigger directly. Otherwise the dynamic feature module is requested and navigation is postponed until the module has successfully been installed.

onRestoreState

open fun onRestoreState(savedState: Bundle): Unit

onSaveState

open fun onSaveState(): Bundle?

Called to ask for a SavedState representing the Navigator's state. This will be restored in onRestoreState.