NavGraphBuilder



DSL for constructing a new NavGraph

Summary

Public constructors

NavGraphBuilder(
    provider: NavigatorProvider,
    id: @IdRes Int,
    startDestination: @IdRes Int
)

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

android
NavGraphBuilder(
    provider: NavigatorProvider,
    startDestination: String,
    route: String?
)

DSL for constructing a new NavGraph

android
NavGraphBuilder(
    provider: NavigatorProvider,
    startDestination: Any,
    route: KClass<*>?,
    typeMap: Map<KTypeNavType<*>>
)

DSL for constructing a new NavGraph

android
NavGraphBuilder(
    provider: NavigatorProvider,
    startDestination: KClass<*>,
    route: KClass<*>?,
    typeMap: Map<KTypeNavType<*>>
)

DSL for constructing a new NavGraph

android

Public functions

Unit

Add the destination to the NavGraphBuilder

android
open NavGraph

Build the NavDestination by calling Navigator.createDestination.

android
Unit
<D : NavDestination> destination(navDestination: NavDestinationBuilder<D>)

Build and add a new destination to the NavGraphBuilder

android
operator Unit

Adds this destination to the NavGraphBuilder

android

Public properties

NavigatorProvider

The NavGraphBuilder's NavigatorProvider.

android

Extension functions

inline Unit

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

android
inline Unit

Construct a new ActivityNavigator.Destination

android
inline Unit
<T : Any> NavGraphBuilder.activity(
    typeMap: Map<KTypeNavType<*>>,
    builder: ActivityNavigatorDestinationBuilder.() -> Unit
)

Construct a new ActivityNavigator.Destination

android
inline Unit
NavGraphBuilder.navigation(
    id: @IdRes Int,
    startDestination: @IdRes Int,
    builder: NavGraphBuilder.() -> Unit
)

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

android
inline Unit
<T : Any> NavGraphBuilder.navigation(
    startDestination: Any,
    typeMap: Map<KTypeNavType<*>>,
    noinline builder: NavGraphBuilder.() -> Unit
)

Construct a nested NavGraph

android
inline Unit
<T : Any> NavGraphBuilder.navigation(
    startDestination: KClass<*>,
    typeMap: Map<KTypeNavType<*>>,
    noinline builder: NavGraphBuilder.() -> Unit
)

Construct a nested NavGraph

android
inline Unit
NavGraphBuilder.navigation(
    startDestination: String,
    route: String,
    builder: NavGraphBuilder.() -> Unit
)

Construct a nested NavGraph

android
Unit
<T : Any> NavGraphBuilder.navigation(
    route: KClass<T>,
    startDestination: Any,
    typeMap: Map<KTypeNavType<*>>,
    builder: NavGraphBuilder.() -> Unit
)

Construct a nested NavGraph

android
Unit
<T : Any> NavGraphBuilder.navigation(
    route: KClass<T>,
    startDestination: KClass<*>,
    typeMap: Map<KTypeNavType<*>>,
    builder: NavGraphBuilder.() -> Unit
)

Construct a nested NavGraph

android

Inherited functions

From androidx.navigation.NavDestinationBuilder
Unit
action(actionId: Int, actionBuilder: NavActionBuilder.() -> Unit)

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

android
Unit
argument(name: String, argumentBuilder: NavArgumentBuilder.() -> Unit)

Add a NavArgument to this destination.

android
Unit
argument(name: String, argument: NavArgument)

Add a NavArgument to this destination.

android
inline Unit
<T : Any> deepLink(basePath: String)

Add a deep link to this destination.

android
Unit
deepLink(navDeepLink: NavDeepLinkDslBuilder.() -> Unit)

Add a deep link to this destination.

android
Unit
deepLink(navDeepLink: NavDeepLink)

Add a deep link to this destination.

android
Unit
deepLink(uriPattern: String)

Add a deep link to this destination.

android
inline Unit
<T : Any> deepLink(basePath: String, noinline navDeepLink: NavDeepLinkDslBuilder.() -> Unit)

Add a deep link to this destination.

android
Unit
<T : Any> deepLink(route: KClass<T>, basePath: String, navDeepLink: NavDeepLinkDslBuilder.() -> Unit)

Add a deep link to this destination.

android
open NavGraph

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

android

Inherited properties

From androidx.navigation.NavDestinationBuilder
Int

The destination's unique ID.

android
CharSequence?

The descriptive label of the destination

android
Navigator<NavGraph>

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

android
String?

The destination's unique route.

android

Public constructors

NavGraphBuilder(
    provider: NavigatorProvider,
    id: @IdRes Int,
    startDestination: @IdRes Int
)

DSL for constructing a new NavGraph

Parameters
provider: NavigatorProvider

navigator used to create the destination

id: @IdRes Int

the graph's unique id

startDestination: @IdRes Int

the starting destination for this NavGraph

Returns
NavGraphBuilder

the newly created NavGraph

NavGraphBuilder(
    provider: NavigatorProvider,
    startDestination: String,
    route: String?
)

DSL for constructing a new NavGraph

Parameters
provider: NavigatorProvider

navigator used to create the destination

startDestination: String

the starting destination's route for this NavGraph

route: String?

the graph's unique route

Returns
NavGraphBuilder

the newly created NavGraph

NavGraphBuilder(
    provider: NavigatorProvider,
    startDestination: Any,
    route: KClass<*>?,
    typeMap: Map<KTypeNavType<*>>
)

DSL for constructing a new NavGraph

Parameters
provider: NavigatorProvider

navigator used to create the destination

startDestination: Any

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.

route: KClass<*>?

the graph's unique route as a KClass

typeMap: Map<KTypeNavType<*>>

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

NavGraphBuilder(
    provider: NavigatorProvider,
    startDestination: KClass<*>,
    route: KClass<*>?,
    typeMap: Map<KTypeNavType<*>>
)

DSL for constructing a new NavGraph

Parameters
provider: NavigatorProvider

navigator used to create the destination

startDestination: KClass<*>

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.

route: KClass<*>?

the graph's unique route as a KClass

typeMap: Map<KTypeNavType<*>>

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 functions

addDestination

fun addDestination(destination: NavDestination): Unit

Add the destination to the NavGraphBuilder

build

open fun build(): NavGraph

Build the NavDestination by calling Navigator.createDestination.

destination

fun <D : NavDestination> destination(navDestination: NavDestinationBuilder<D>): Unit

Build and add a new destination to the NavGraphBuilder

unaryPlus

operator fun NavDestination.unaryPlus(): Unit

Adds this destination to the NavGraphBuilder

Public properties

provider

val providerNavigatorProvider

The NavGraphBuilder's NavigatorProvider.

Extension functions

inline fun NavGraphBuilder.activity(id: @IdRes Int, builder: ActivityNavigatorDestinationBuilder.() -> Unit): Unit

Construct a new ActivityNavigator.Destination

inline fun <T : Any> NavGraphBuilder.activity(
    typeMap: Map<KTypeNavType<*>> = emptyMap(),
    builder: ActivityNavigatorDestinationBuilder.() -> Unit
): Unit

Construct a new ActivityNavigator.Destination

Parameters
<T : Any>

destination's unique route from a KClass

typeMap: Map<KTypeNavType<*>> = emptyMap()

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

builder: ActivityNavigatorDestinationBuilder.() -> Unit

the builder used to construct the fragment destination

navigation

inline fun NavGraphBuilder.navigation(
    id: @IdRes Int,
    startDestination: @IdRes Int,
    builder: NavGraphBuilder.() -> Unit
): Unit

Construct a nested NavGraph

Parameters
id: @IdRes Int

the destination's unique id

startDestination: @IdRes Int

the starting destination for this NavGraph

builder: NavGraphBuilder.() -> Unit

the builder used to construct the graph

Returns
Unit

the newly constructed nested NavGraph

navigation

inline fun <T : Any> NavGraphBuilder.navigation(
    startDestination: Any,
    typeMap: Map<KTypeNavType<*>> = emptyMap(),
    noinline builder: NavGraphBuilder.() -> Unit
): Unit

Construct a nested NavGraph

Parameters
<T : Any>

the graph's unique route from a KClass

startDestination: Any

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.

typeMap: Map<KTypeNavType<*>> = emptyMap()

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

noinline builder: NavGraphBuilder.() -> Unit

the builder used to construct the graph

Returns
Unit

the newly constructed nested NavGraph

navigation

inline fun <T : Any> NavGraphBuilder.navigation(
    startDestination: KClass<*>,
    typeMap: Map<KTypeNavType<*>> = emptyMap(),
    noinline builder: NavGraphBuilder.() -> Unit
): Unit

Construct a nested NavGraph

Parameters
<T : Any>

the graph's unique route from a KClass

startDestination: KClass<*>

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.

typeMap: Map<KTypeNavType<*>> = emptyMap()

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

noinline builder: NavGraphBuilder.() -> Unit

the builder used to construct the graph

Returns
Unit

the newly constructed nested NavGraph

navigation

inline fun NavGraphBuilder.navigation(
    startDestination: String,
    route: String,
    builder: NavGraphBuilder.() -> Unit
): Unit

Construct a nested NavGraph

Parameters
startDestination: String

the starting destination's route for this NavGraph

route: String

the destination's unique route

builder: NavGraphBuilder.() -> Unit

the builder used to construct the graph

Returns
Unit

the newly constructed nested NavGraph

navigation

fun <T : Any> NavGraphBuilder.navigation(
    route: KClass<T>,
    startDestination: Any,
    typeMap: Map<KTypeNavType<*>> = emptyMap(),
    builder: NavGraphBuilder.() -> Unit
): Unit

Construct a nested NavGraph

Parameters
route: KClass<T>

the graph's unique route from a KClass

startDestination: Any

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.

typeMap: Map<KTypeNavType<*>> = emptyMap()

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

builder: NavGraphBuilder.() -> Unit

the builder used to construct the graph

Returns
Unit

the newly constructed nested NavGraph

navigation

fun <T : Any> NavGraphBuilder.navigation(
    route: KClass<T>,
    startDestination: KClass<*>,
    typeMap: Map<KTypeNavType<*>> = emptyMap(),
    builder: NavGraphBuilder.() -> Unit
): Unit

Construct a nested NavGraph

Parameters
route: KClass<T>

the graph's unique route from KClass

startDestination: KClass<*>

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.

typeMap: Map<KTypeNavType<*>> = emptyMap()

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

builder: NavGraphBuilder.() -> Unit

the builder used to construct the graph

Returns
Unit

the newly constructed nested NavGraph