NavGraphBuilder


@NavDestinationDsl
public class NavGraphBuilder extends NavDestinationBuilder

Known direct subclasses

DSL for constructing a new NavGraph

Summary

Public constructors

NavGraphBuilder(
    @NonNull NavigatorProvider provider,
    @IdRes int id,
    @IdRes int startDestination
)

This method is deprecated. Use routes to build your NavGraph instead

NavGraphBuilder(
    @NonNull NavigatorProvider provider,
    @NonNull String startDestination,
    String route
)

DSL for constructing a new NavGraph

NavGraphBuilder(
    @NonNull NavigatorProvider provider,
    @NonNull Object startDestination,
    KClass<@NonNull ?> route,
    @NonNull Map<@NonNull KType, @NonNull NavType<@NonNull ?>> typeMap
)

DSL for constructing a new NavGraph

NavGraphBuilder(
    @NonNull NavigatorProvider provider,
    @NonNull KClass<@NonNull ?> startDestination,
    KClass<@NonNull ?> route,
    @NonNull Map<@NonNull KType, @NonNull NavType<@NonNull ?>> typeMap
)

DSL for constructing a new NavGraph

Public methods

final void

Add the destination to the NavGraphBuilder

@NonNull NavGraph

Build the NavDestination by calling Navigator.createDestination.

final void
<D extends NavDestination> destination(
    @NonNull NavDestinationBuilder<@NonNull D> navDestination
)

Build and add a new destination to the NavGraphBuilder

final @NonNull NavigatorProvider

The NavGraphBuilder's NavigatorProvider.

final void

Adds this destination to the NavGraphBuilder

Extension functions

final void

This method is deprecated. Use routes to build your ActivityDestination instead

final void

Construct a new ActivityNavigator.Destination

final void

Construct a new ActivityNavigator.Destination

final void

This method is deprecated. Use routes to create your DialogFragmentDestination instead

final void

Construct a new DialogFragmentNavigator.Destination

final void

Construct a new DialogFragmentNavigator.Destination

final void

This method is deprecated. Use routes to create your DialogFragmentDestination instead

final void

Construct a new DialogFragmentNavigator.Destination

final void

Construct a new DialogFragmentNavigator.Destination

final void
<F extends Fragment> FragmentNavigatorDestinationBuilderKt.fragment(
    @NonNull NavGraphBuilder receiver,
    @IdRes int id
)

This method is deprecated. Use routes to create your FragmentDestination instead

final void

Construct a new FragmentNavigator.Destination

final void
<F extends Fragment, T extends Object> FragmentNavigatorDestinationBuilderKt.fragment(
    @NonNull NavGraphBuilder receiver,
    @NonNull Map<@NonNull KType, @NonNull NavType<@NonNull ?>> typeMap
)

Construct a new FragmentNavigator.Destination

final void

This method is deprecated. Use routes to create your FragmentDestination instead

final void

Construct a new FragmentNavigator.Destination

final void

Construct a new FragmentNavigator.Destination

final void
NavGraphBuilderKt.navigation(
    @NonNull NavGraphBuilder receiver,
    @IdRes int id,
    @IdRes int startDestination,
    @ExtensionFunctionType @NonNull Function1<@NonNull NavGraphBuilderUnit> builder
)

This method is deprecated. Use routes to build your nested NavGraph instead

final void
<T extends Object> NavGraphBuilderKt.navigation(
    @NonNull NavGraphBuilder receiver,
    @NonNull Object startDestination,
    @NonNull Map<@NonNull KType, @NonNull NavType<@NonNull ?>> typeMap,
    @ExtensionFunctionType @NonNull Function1<@NonNull NavGraphBuilderUnit> builder
)

Construct a nested NavGraph

final void
<T extends Object> NavGraphBuilderKt.navigation(
    @NonNull NavGraphBuilder receiver,
    @NonNull KClass<@NonNull ?> startDestination,
    @NonNull Map<@NonNull KType, @NonNull NavType<@NonNull ?>> typeMap,
    @ExtensionFunctionType @NonNull Function1<@NonNull NavGraphBuilderUnit> builder
)

Construct a nested NavGraph

final void
NavGraphBuilderKt.navigation(
    @NonNull NavGraphBuilder receiver,
    @NonNull String startDestination,
    @NonNull String route,
    @ExtensionFunctionType @NonNull Function1<@NonNull NavGraphBuilderUnit> builder
)

Construct a nested NavGraph

Inherited methods

From androidx.navigation.NavDestinationBuilder
final void
action(
    int actionId,
    @ExtensionFunctionType @NonNull Function1<@NonNull NavActionBuilderUnit> actionBuilder
)

This method is deprecated. Building NavDestinations using IDs with the Kotlin DSL has been deprecated in favor of using routes.

final void
argument(
    @NonNull String name,
    @ExtensionFunctionType @NonNull Function1<@NonNull NavArgumentBuilderUnit> argumentBuilder
)

Add a NavArgument to this destination.

final void

Add a NavArgument to this destination.

final void
<T extends Object> deepLinkSafeArgs(@NonNull String basePath)

Add a deep link to this destination.

final void

Add a deep link to this destination.

final void

Add a deep link to this destination.

final void
deepLink(@NonNull String uriPattern)

Add a deep link to this destination.

final void
<T extends Object> deepLink(
    @NonNull String basePath,
    @ExtensionFunctionType @NonNull Function1<@NonNull NavDeepLinkDslBuilderUnit> navDeepLink
)

Add a deep link to this destination.

final int

The destination's unique ID.

final CharSequence

The descriptive label of the destination

final @NonNull Navigator<@NonNull NavGraph>

The navigator the destination that will be used in instantiateDestination to create the destination.

final String

The destination's unique route.

@NonNull NavGraph

Instantiate a new instance of D that will be passed to build.

final void

The descriptive label of the destination

Public constructors

Added in 1.0.0
public NavGraphBuilder(
    @NonNull NavigatorProvider provider,
    @IdRes int id,
    @IdRes int startDestination
)

DSL for constructing a new NavGraph

Parameters
@NonNull NavigatorProvider provider

navigator used to create the destination

@IdRes int id

the graph's unique id

@IdRes int startDestination

the starting destination for this NavGraph

Returns
NavGraphBuilder

the newly created NavGraph

public NavGraphBuilder(
    @NonNull NavigatorProvider provider,
    @NonNull String startDestination,
    String route
)

DSL for constructing a new NavGraph

Parameters
@NonNull NavigatorProvider provider

navigator used to create the destination

@NonNull String startDestination

the starting destination's route for this NavGraph

String route

the graph's unique route

Returns
NavGraphBuilder

the newly created NavGraph

public NavGraphBuilder(
    @NonNull NavigatorProvider provider,
    @NonNull Object startDestination,
    KClass<@NonNull ?> route,
    @NonNull Map<@NonNull KType, @NonNull NavType<@NonNull ?>> typeMap
)

DSL for constructing a new NavGraph

Parameters
@NonNull NavigatorProvider provider

navigator used to create the destination

@NonNull Object startDestination

the starting destination's route as an Object for this NavGraph. The respective NavDestination must be added with route from a KClass in order to match.

KClass<@NonNull ?> route

the graph's unique route as a KClass

@NonNull Map<@NonNull KType, @NonNull NavType<@NonNull ?>> typeMap

A mapping of KType to custom NavType<*> in the route. May be empty if route does not use custom NavTypes.

Returns
NavGraphBuilder

the newly created NavGraph

public NavGraphBuilder(
    @NonNull NavigatorProvider provider,
    @NonNull KClass<@NonNull ?> startDestination,
    KClass<@NonNull ?> route,
    @NonNull Map<@NonNull KType, @NonNull NavType<@NonNull ?>> typeMap
)

DSL for constructing a new NavGraph

Parameters
@NonNull NavigatorProvider provider

navigator used to create the destination

@NonNull KClass<@NonNull ?> startDestination

the starting destination's route as a KClass for this NavGraph. The respective NavDestination must be added with route from a KClass in order to match.

KClass<@NonNull ?> route

the graph's unique route as a KClass

@NonNull Map<@NonNull KType, @NonNull NavType<@NonNull ?>> typeMap

A mapping of KType to custom NavType<*> in the route. May be empty if route does not use custom NavTypes.

Returns
NavGraphBuilder

the newly created NavGraph

Public methods

addDestination

Added in 1.0.0
public final void addDestination(@NonNull NavDestination destination)

Add the destination to the NavGraphBuilder

build

public @NonNull NavGraph build()

Build the NavDestination by calling Navigator.createDestination.

destination

public final void <D extends NavDestination> destination(
    @NonNull NavDestinationBuilder<@NonNull D> navDestination
)

Build and add a new destination to the NavGraphBuilder

getProvider

Added in 1.0.0
public final @NonNull NavigatorProvider getProvider()

The NavGraphBuilder's NavigatorProvider.

unaryPlus

Added in 1.0.0
public final void unaryPlus(@NonNull NavDestination receiver)

Adds this destination to the NavGraphBuilder

Extension functions

ActivityNavigatorDestinationBuilderKt.activity

public final void ActivityNavigatorDestinationBuilderKt.activity(
    @NonNull NavGraphBuilder receiver,
    @IdRes int id,
    @ExtensionFunctionType @NonNull Function1<@NonNull ActivityNavigatorDestinationBuilderUnit> builder
)

Construct a new ActivityNavigator.Destination

ActivityNavigatorDestinationBuilderKt.activity

public final void ActivityNavigatorDestinationBuilderKt.activity(
    @NonNull NavGraphBuilder receiver,
    @NonNull String route,
    @ExtensionFunctionType @NonNull Function1<@NonNull ActivityNavigatorDestinationBuilderUnit> builder
)

Construct a new ActivityNavigator.Destination

ActivityNavigatorDestinationBuilderKt.activity

public final void <T extends Object> ActivityNavigatorDestinationBuilderKt.activity(
    @NonNull NavGraphBuilder receiver,
    @NonNull Map<@NonNull KType, @NonNull NavType<@NonNull ?>> typeMap,
    @ExtensionFunctionType @NonNull Function1<@NonNull ActivityNavigatorDestinationBuilderUnit> builder
)

Construct a new ActivityNavigator.Destination

Parameters
<T extends Object>

destination's unique route from a KClass

@NonNull Map<@NonNull KType, @NonNull NavType<@NonNull ?>> typeMap

map of destination arguments' kotlin type KType to its respective custom NavType. May be empty if T does not use custom NavTypes.

@ExtensionFunctionType @NonNull Function1<@NonNull ActivityNavigatorDestinationBuilderUnit> builder

the builder used to construct the fragment destination

DialogFragmentNavigatorDestinationBuilderKt.dialog

public final void <F extends DialogFragment> DialogFragmentNavigatorDestinationBuilderKt.dialog(
    @NonNull NavGraphBuilder receiver,
    @IdRes int id
)

Construct a new DialogFragmentNavigator.Destination

Parameters
@IdRes int id

the destination's unique id

DialogFragmentNavigatorDestinationBuilderKt.dialog

public final void <F extends DialogFragment> DialogFragmentNavigatorDestinationBuilderKt.dialog(
    @NonNull NavGraphBuilder receiver,
    @NonNull String route
)

Construct a new DialogFragmentNavigator.Destination

Parameters
@NonNull String route

the destination's unique route

DialogFragmentNavigatorDestinationBuilderKt.dialog

public final void <F extends DialogFragment, T extends Object> DialogFragmentNavigatorDestinationBuilderKt.dialog(
    @NonNull NavGraphBuilder receiver,
    @NonNull Map<@NonNull KType, @NonNull NavType<@NonNull ?>> typeMap
)

Construct a new DialogFragmentNavigator.Destination

Parameters
<T extends Object>

the destination's unique route from a KClass

@NonNull Map<@NonNull KType, @NonNull NavType<@NonNull ?>> typeMap

map of destination arguments' kotlin type KType to its respective custom NavType. May be empty if T does not use custom NavTypes.

DialogFragmentNavigatorDestinationBuilderKt.dialog

public final void <F extends DialogFragment> DialogFragmentNavigatorDestinationBuilderKt.dialog(
    @NonNull NavGraphBuilder receiver,
    @IdRes int id,
    @ExtensionFunctionType @NonNull Function1<@NonNull DialogFragmentNavigatorDestinationBuilderUnit> builder
)

Construct a new DialogFragmentNavigator.Destination

Parameters
@IdRes int id

the destination's unique id

@ExtensionFunctionType @NonNull Function1<@NonNull DialogFragmentNavigatorDestinationBuilderUnit> builder

the builder used to construct the fragment destination

DialogFragmentNavigatorDestinationBuilderKt.dialog

public final void <F extends DialogFragment> DialogFragmentNavigatorDestinationBuilderKt.dialog(
    @NonNull NavGraphBuilder receiver,
    @NonNull String route,
    @ExtensionFunctionType @NonNull Function1<@NonNull DialogFragmentNavigatorDestinationBuilderUnit> builder
)

Construct a new DialogFragmentNavigator.Destination

Parameters
@NonNull String route

the destination's unique route

@ExtensionFunctionType @NonNull Function1<@NonNull DialogFragmentNavigatorDestinationBuilderUnit> builder

the builder used to construct the fragment destination

DialogFragmentNavigatorDestinationBuilderKt.dialog

public final void <F extends DialogFragment, T extends Object> DialogFragmentNavigatorDestinationBuilderKt.dialog(
    @NonNull NavGraphBuilder receiver,
    @NonNull Map<@NonNull KType, @NonNull NavType<@NonNull ?>> typeMap,
    @ExtensionFunctionType @NonNull Function1<@NonNull DialogFragmentNavigatorDestinationBuilderUnit> builder
)

Construct a new DialogFragmentNavigator.Destination

Parameters
<T extends Object>

the destination's unique route from a KClass

@NonNull Map<@NonNull KType, @NonNull NavType<@NonNull ?>> typeMap

map of destination arguments' kotlin type KType to its respective custom NavType. May be empty if T does not use custom NavTypes.

@ExtensionFunctionType @NonNull Function1<@NonNull DialogFragmentNavigatorDestinationBuilderUnit> builder

the builder used to construct the fragment destination

FragmentNavigatorDestinationBuilderKt.fragment

public final void <F extends Fragment> FragmentNavigatorDestinationBuilderKt.fragment(
    @NonNull NavGraphBuilder receiver,
    @IdRes int id
)

Construct a new FragmentNavigator.Destination

Parameters
@IdRes int id

the destination's unique id

FragmentNavigatorDestinationBuilderKt.fragment

public final void <F extends Fragment> FragmentNavigatorDestinationBuilderKt.fragment(
    @NonNull NavGraphBuilder receiver,
    @NonNull String route
)

Construct a new FragmentNavigator.Destination

Parameters
@NonNull String route

the destination's unique route

FragmentNavigatorDestinationBuilderKt.fragment

public final void <F extends Fragment, T extends Object> FragmentNavigatorDestinationBuilderKt.fragment(
    @NonNull NavGraphBuilder receiver,
    @NonNull Map<@NonNull KType, @NonNull NavType<@NonNull ?>> typeMap
)

Construct a new FragmentNavigator.Destination

Parameters
<T extends Object>

the destination's unique route from a KClass

@NonNull Map<@NonNull KType, @NonNull NavType<@NonNull ?>> typeMap

map of destination arguments' kotlin type KType to its respective custom NavType. May be empty if T does not use custom NavTypes.

FragmentNavigatorDestinationBuilderKt.fragment

public final void <F extends Fragment> FragmentNavigatorDestinationBuilderKt.fragment(
    @NonNull NavGraphBuilder receiver,
    @IdRes int id,
    @ExtensionFunctionType @NonNull Function1<@NonNull FragmentNavigatorDestinationBuilderUnit> builder
)

Construct a new FragmentNavigator.Destination

Parameters
@IdRes int id

the destination's unique id

@ExtensionFunctionType @NonNull Function1<@NonNull FragmentNavigatorDestinationBuilderUnit> builder

the builder used to construct the fragment destination

FragmentNavigatorDestinationBuilderKt.fragment

public final void <F extends Fragment> FragmentNavigatorDestinationBuilderKt.fragment(
    @NonNull NavGraphBuilder receiver,
    @NonNull String route,
    @ExtensionFunctionType @NonNull Function1<@NonNull FragmentNavigatorDestinationBuilderUnit> builder
)

Construct a new FragmentNavigator.Destination

Parameters
@NonNull String route

the destination's unique route

@ExtensionFunctionType @NonNull Function1<@NonNull FragmentNavigatorDestinationBuilderUnit> builder

the builder used to construct the fragment destination

FragmentNavigatorDestinationBuilderKt.fragment

public final void <F extends Fragment, T extends Object> FragmentNavigatorDestinationBuilderKt.fragment(
    @NonNull NavGraphBuilder receiver,
    @NonNull Map<@NonNull KType, @NonNull NavType<@NonNull ?>> typeMap,
    @ExtensionFunctionType @NonNull Function1<@NonNull FragmentNavigatorDestinationBuilderUnit> builder
)

Construct a new FragmentNavigator.Destination

Parameters
<T extends Object>

the destination's unique route from a KClass

@NonNull Map<@NonNull KType, @NonNull NavType<@NonNull ?>> typeMap

map of destination arguments' kotlin type KType to its respective custom NavType. May be empty if T does not use custom NavTypes.

@ExtensionFunctionType @NonNull Function1<@NonNull FragmentNavigatorDestinationBuilderUnit> builder

the builder used to construct the fragment destination

NavGraphBuilderKt.navigation

public final void NavGraphBuilderKt.navigation(
    @NonNull NavGraphBuilder receiver,
    @IdRes int id,
    @IdRes int startDestination,
    @ExtensionFunctionType @NonNull Function1<@NonNull NavGraphBuilderUnit> builder
)

Construct a nested NavGraph

Parameters
@IdRes int id

the destination's unique id

@IdRes int startDestination

the starting destination for this NavGraph

@ExtensionFunctionType @NonNull Function1<@NonNull NavGraphBuilderUnit> builder

the builder used to construct the graph

Returns
void

the newly constructed nested NavGraph

NavGraphBuilderKt.navigation

public final void <T extends Object> NavGraphBuilderKt.navigation(
    @NonNull NavGraphBuilder receiver,
    @NonNull Object startDestination,
    @NonNull Map<@NonNull KType, @NonNull NavType<@NonNull ?>> typeMap,
    @ExtensionFunctionType @NonNull Function1<@NonNull NavGraphBuilderUnit> builder
)

Construct a nested NavGraph

Parameters
<T extends Object>

the graph's unique route from a KClass

@NonNull Object startDestination

the starting destination's route from an Object for this NavGraph. The respective NavDestination must be added with route from a KClass in order to match.

@NonNull Map<@NonNull KType, @NonNull NavType<@NonNull ?>> typeMap

A mapping of KType to custom NavType<*> in the T. May be empty if T does not use custom NavTypes.

@ExtensionFunctionType @NonNull Function1<@NonNull NavGraphBuilderUnit> builder

the builder used to construct the graph

Returns
void

the newly constructed nested NavGraph

NavGraphBuilderKt.navigation

public final void <T extends Object> NavGraphBuilderKt.navigation(
    @NonNull NavGraphBuilder receiver,
    @NonNull KClass<@NonNull ?> startDestination,
    @NonNull Map<@NonNull KType, @NonNull NavType<@NonNull ?>> typeMap,
    @ExtensionFunctionType @NonNull Function1<@NonNull NavGraphBuilderUnit> builder
)

Construct a nested NavGraph

Parameters
<T extends Object>

the graph's unique route from a KClass

@NonNull KClass<@NonNull ?> startDestination

the starting destination's route from a KClass for this NavGraph. The respective NavDestination must be added with route from a KClass in order to match.

@NonNull Map<@NonNull KType, @NonNull NavType<@NonNull ?>> typeMap

A mapping of KType to custom NavType<*> in the T. May be empty if T does not use custom NavTypes.

@ExtensionFunctionType @NonNull Function1<@NonNull NavGraphBuilderUnit> builder

the builder used to construct the graph

Returns
void

the newly constructed nested NavGraph

NavGraphBuilderKt.navigation

public final void NavGraphBuilderKt.navigation(
    @NonNull NavGraphBuilder receiver,
    @NonNull String startDestination,
    @NonNull String route,
    @ExtensionFunctionType @NonNull Function1<@NonNull NavGraphBuilderUnit> builder
)

Construct a nested NavGraph

Parameters
@NonNull String startDestination

the starting destination's route for this NavGraph

@NonNull String route

the destination's unique route

@ExtensionFunctionType @NonNull Function1<@NonNull NavGraphBuilderUnit> builder

the builder used to construct the graph

Returns
void

the newly constructed nested NavGraph