NavGraphBuilder


Known direct subclasses

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

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

DSL for constructing a new NavGraph

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

DSL for constructing a new NavGraph

Cmn
android

Public functions

Unit

Add the destination to the NavGraphBuilder

Cmn
android
open NavGraph

Build the NavDestination by calling Navigator.createDestination.

Cmn
android
Unit
NavDestination> destination(navDestination: NavDestinationBuilder)

Build and add a new destination to the NavGraphBuilder

Cmn
android
operator Unit

Adds this destination to the NavGraphBuilder

Cmn
android

Public properties

NavigatorProvider

The NavGraphBuilder's NavigatorProvider.

Cmn
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
Any> NavGraphBuilder.activity(
    typeMap: Map<KTypeNavType<*>>,
    builder: ActivityNavigatorDestinationBuilder.() -> Unit
)

Construct a new ActivityNavigator.Destination

android
inline Unit
DialogFragment> NavGraphBuilder.dialog(id: @IdRes Int)

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

android
inline Unit
DialogFragment> NavGraphBuilder.dialog(route: String)

Construct a new DialogFragmentNavigator.Destination

android
inline Unit
DialogFragment, T : Any> NavGraphBuilder.dialog(
    typeMap: Map<KTypeNavType<*>>
)

Construct a new DialogFragmentNavigator.Destination

android
inline Unit
DialogFragment> NavGraphBuilder.dialog(
    id: @IdRes Int,
    builder: DialogFragmentNavigatorDestinationBuilder.() -> Unit
)

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

android
inline Unit
DialogFragment> NavGraphBuilder.dialog(
    route: String,
    builder: DialogFragmentNavigatorDestinationBuilder.() -> Unit
)

Construct a new DialogFragmentNavigator.Destination

android
inline Unit
DialogFragment, T : Any> NavGraphBuilder.dialog(
    typeMap: Map<KTypeNavType<*>>,
    builder: DialogFragmentNavigatorDestinationBuilder.() -> Unit
)

Construct a new DialogFragmentNavigator.Destination

android
inline Unit

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

android
inline Unit
Fragment> NavGraphBuilder.fragment(route: String)

Construct a new FragmentNavigator.Destination

android
inline Unit
Fragment, T : Any> NavGraphBuilder.fragment(
    typeMap: Map<KTypeNavType<*>>
)

Construct a new FragmentNavigator.Destination

android
inline Unit

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

android
inline Unit

Construct a new FragmentNavigator.Destination

android
inline Unit
Fragment, T : Any> NavGraphBuilder.fragment(
    typeMap: Map<KTypeNavType<*>>,
    builder: FragmentNavigatorDestinationBuilder.() -> Unit
)

Construct a new FragmentNavigator.Destination

android
Unit
NavGraphBuilder.bottomSheet(
    route: String,
    arguments: List<NamedNavArgument>,
    deepLinks: List<NavDeepLink>,
    content: @Composable ColumnScope.(backstackEntry: NavBackStackEntry) -> Unit
)

Add the content as bottom sheet content to the NavGraphBuilder

android
inline Unit
Any> NavGraphBuilder.bottomSheet(
    typeMap: Map<KTypeNavType<*>>,
    arguments: List<NamedNavArgument>,
    deepLinks: List<NavDeepLink>,
    noinline content: @Composable ColumnScope.(backstackEntry: NavBackStackEntry) -> Unit
)

Add the content as bottom sheet content to the NavGraphBuilder

android
Unit
NavGraphBuilder.composable(
    route: String,
    arguments: List<NamedNavArgument>,
    deepLinks: List<NavDeepLink>,
    content: @Composable (NavBackStackEntry) -> Unit
)

Utility function for building Wear Compose navigation graphs.

android
inline Unit
Any> NavGraphBuilder.composable(
    typeMap: Map<KTypeNavType<*>>,
    deepLinks: List<NavDeepLink>,
    noinline enterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)?,
    noinline exitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)?,
    noinline popEnterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)?,
    noinline popExitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)?,
    noinline sizeTransform: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> SizeTransform?)?,
    noinline content: @Composable AnimatedContentScope.(NavBackStackEntry) -> Unit
)

Add the Composable to the NavGraphBuilder

Cmn
Unit
Any> NavGraphBuilder.composable(
    route: KClass,
    typeMap: Map<KTypeNavType<*>>,
    deepLinks: List<NavDeepLink>,
    enterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)?,
    exitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)?,
    popEnterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)?,
    popExitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)?,
    sizeTransform: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> SizeTransform?)?,
    content: @Composable AnimatedContentScope.(NavBackStackEntry) -> Unit
)

Add the Composable to the NavGraphBuilder

Cmn
Unit
NavGraphBuilder.composable(
    route: String,
    arguments: List<NamedNavArgument>,
    deepLinks: List<NavDeepLink>,
    enterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)?,
    exitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)?,
    popEnterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)?,
    popExitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)?,
    sizeTransform: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> SizeTransform?)?,
    content: @Composable AnimatedContentScope.(NavBackStackEntry) -> Unit
)

Add the Composable to the NavGraphBuilder

Cmn
inline Unit
Any> NavGraphBuilder.dialog(
    typeMap: Map<KTypeNavType<*>>,
    deepLinks: List<NavDeepLink>,
    dialogProperties: DialogProperties,
    noinline content: @Composable (NavBackStackEntry) -> Unit
)

Add the Composable to the NavGraphBuilder that will be hosted within a androidx.compose.ui.window.Dialog.

Cmn
Unit
Any> NavGraphBuilder.dialog(
    route: KClass,
    typeMap: Map<KTypeNavType<*>>,
    deepLinks: List<NavDeepLink>,
    dialogProperties: DialogProperties,
    content: @Composable (NavBackStackEntry) -> Unit
)

Add the Composable to the NavGraphBuilder that will be hosted within a androidx.compose.ui.window.Dialog.

Cmn
Unit
NavGraphBuilder.dialog(
    route: String,
    arguments: List<NamedNavArgument>,
    deepLinks: List<NavDeepLink>,
    dialogProperties: DialogProperties,
    content: @Composable (NavBackStackEntry) -> Unit
)

Add the Composable to the NavGraphBuilder that will be hosted within a androidx.compose.ui.window.Dialog.

Cmn
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
Any> NavGraphBuilder.navigation(
    startDestination: Any,
    typeMap: Map<KTypeNavType<*>>,
    noinline builder: NavGraphBuilder.() -> Unit
)

Construct a nested NavGraph

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

Construct a nested NavGraph

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

Construct a nested NavGraph

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

Construct a nested NavGraph

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

Construct a nested NavGraph

Cmn
inline Unit
Any> NavGraphBuilder.navigation(
    startDestination: Any,
    typeMap: Map<KTypeNavType<*>>,
    deepLinks: List<NavDeepLink>,
    noinline enterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)?,
    noinline exitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)?,
    noinline popEnterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)?,
    noinline popExitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)?,
    noinline sizeTransform: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> SizeTransform?)?,
    noinline builder: NavGraphBuilder.() -> Unit
)

Construct a nested NavGraph

Cmn
inline Unit
Any> NavGraphBuilder.navigation(
    startDestination: KClass<*>,
    typeMap: Map<KTypeNavType<*>>,
    deepLinks: List<NavDeepLink>,
    noinline enterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)?,
    noinline exitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)?,
    noinline popEnterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)?,
    noinline popExitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)?,
    noinline sizeTransform: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> SizeTransform?)?,
    noinline builder: NavGraphBuilder.() -> Unit
)

Construct a nested NavGraph

Cmn
Unit
Any> NavGraphBuilder.navigation(
    startDestination: Any,
    route: KClass,
    typeMap: Map<KTypeNavType<*>>,
    deepLinks: List<NavDeepLink>,
    enterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)?,
    exitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)?,
    popEnterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)?,
    popExitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)?,
    sizeTransform: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> SizeTransform?)?,
    builder: NavGraphBuilder.() -> Unit
)

Construct a nested NavGraph

Cmn
Unit
Any> NavGraphBuilder.navigation(
    startDestination: KClass<*>,
    route: KClass,
    typeMap: Map<KTypeNavType<*>>,
    deepLinks: List<NavDeepLink>,
    enterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)?,
    exitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)?,
    popEnterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)?,
    popExitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)?,
    sizeTransform: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> SizeTransform?)?,
    builder: NavGraphBuilder.() -> Unit
)

Construct a nested NavGraph

Cmn
Unit
NavGraphBuilder.navigation(
    startDestination: String,
    route: String,
    arguments: List<NamedNavArgument>,
    deepLinks: List<NavDeepLink>,
    enterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)?,
    exitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)?,
    popEnterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)?,
    popExitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)?,
    sizeTransform: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> SizeTransform?)?,
    builder: NavGraphBuilder.() -> Unit
)

Construct a nested NavGraph

Cmn

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.

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

Add a NavArgument to this destination.

Cmn
android
inline Unit
Any> deepLink(basePath: String)

Add a deep link to this destination.

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

Add a deep link to this destination.

Cmn
android
Unit
deepLink(navDeepLink: NavDeepLink)

Add a deep link to this destination.

Cmn
android
Unit
Any> deepLink(uriPattern: String)

Add a deep link to this destination.

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

Add a deep link to this destination.

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

Add a deep link to this destination.

Cmn
android
open NavGraph

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

Cmn
android

Inherited properties

From androidx.navigation.NavDestinationBuilder
Int

The destination's unique ID.

android
CharSequence?

The descriptive label of the destination

Cmn
android
Navigator<NavGraph>

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

Cmn
android
String?

The destination's unique route.

Cmn
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 NavDestination> destination(navDestination: NavDestinationBuilder): 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 Any> NavGraphBuilder.activity(
    typeMap: Map<KTypeNavType<*>> = emptyMap(),
    builder: ActivityNavigatorDestinationBuilder.() -> Unit
): Unit

Construct a new ActivityNavigator.Destination

Parameters
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

inline fun DialogFragment> NavGraphBuilder.dialog(id: @IdRes Int): Unit

Construct a new DialogFragmentNavigator.Destination

Parameters
id: @IdRes Int

the destination's unique id

inline fun DialogFragment> NavGraphBuilder.dialog(route: String): Unit

Construct a new DialogFragmentNavigator.Destination

Parameters
route: String

the destination's unique route

inline fun DialogFragment, T : Any> NavGraphBuilder.dialog(
    typeMap: Map<KTypeNavType<*>> = emptyMap()
): Unit

Construct a new DialogFragmentNavigator.Destination

Parameters
Any>

the 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.

inline fun DialogFragment> NavGraphBuilder.dialog(
    id: @IdRes Int,
    builder: DialogFragmentNavigatorDestinationBuilder.() -> Unit
): Unit

Construct a new DialogFragmentNavigator.Destination

Parameters
id: @IdRes Int

the destination's unique id

builder: DialogFragmentNavigatorDestinationBuilder.() -> Unit

the builder used to construct the fragment destination

inline fun DialogFragment> NavGraphBuilder.dialog(
    route: String,
    builder: DialogFragmentNavigatorDestinationBuilder.() -> Unit
): Unit

Construct a new DialogFragmentNavigator.Destination

Parameters
route: String

the destination's unique route

builder: DialogFragmentNavigatorDestinationBuilder.() -> Unit

the builder used to construct the fragment destination

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

Construct a new DialogFragmentNavigator.Destination

Parameters
Any>

the 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: DialogFragmentNavigatorDestinationBuilder.() -> Unit

the builder used to construct the fragment destination

inline fun Fragment> NavGraphBuilder.fragment(id: @IdRes Int): Unit

Construct a new FragmentNavigator.Destination

Parameters
id: @IdRes Int

the destination's unique id

inline fun Fragment> NavGraphBuilder.fragment(route: String): Unit

Construct a new FragmentNavigator.Destination

Parameters
route: String

the destination's unique route

inline fun Fragment, T : Any> NavGraphBuilder.fragment(
    typeMap: Map<KTypeNavType<*>> = emptyMap()
): Unit

Construct a new FragmentNavigator.Destination

Parameters
Any>

the 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.

inline fun Fragment> NavGraphBuilder.fragment(id: @IdRes Int, builder: FragmentNavigatorDestinationBuilder.() -> Unit): Unit

Construct a new FragmentNavigator.Destination

Parameters
id: @IdRes Int

the destination's unique id

builder: FragmentNavigatorDestinationBuilder.() -> Unit

the builder used to construct the fragment destination

inline fun Fragment> NavGraphBuilder.fragment(route: String, builder: FragmentNavigatorDestinationBuilder.() -> Unit): Unit

Construct a new FragmentNavigator.Destination

Parameters
route: String

the destination's unique route

builder: FragmentNavigatorDestinationBuilder.() -> Unit

the builder used to construct the fragment destination

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

Construct a new FragmentNavigator.Destination

Parameters
Any>

the 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: FragmentNavigatorDestinationBuilder.() -> Unit

the builder used to construct the fragment destination

fun NavGraphBuilder.bottomSheet(
    route: String,
    arguments: List<NamedNavArgument> = emptyList(),
    deepLinks: List<NavDeepLink> = emptyList(),
    content: @Composable ColumnScope.(backstackEntry: NavBackStackEntry) -> Unit
): Unit

Add the content as bottom sheet content to the NavGraphBuilder

import androidx.compose.material.Text
import androidx.compose.material.navigation.ModalBottomSheetLayout
import androidx.compose.material.navigation.bottomSheet
import androidx.compose.material.navigation.rememberBottomSheetNavigator
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.rememberNavController

val bottomSheetNavigator = rememberBottomSheetNavigator()
val navController = rememberNavController(bottomSheetNavigator)

ModalBottomSheetLayout(bottomSheetNavigator) {
    NavHost(navController, Destinations.Home) {
        composable(Destinations.Home) {
            HomeScreen(
                showSheet = {
                    navController.navigate(Destinations.Sheet + "?arg=From Home Screen")
                },
                showFeed = { navController.navigate(Destinations.Feed) },
            )
        }
        composable(Destinations.Feed) { Text("Feed!") }
        bottomSheet(Destinations.Sheet + "?arg={arg}") { backstackEntry ->
            val arg = backstackEntry.arguments?.getString("arg") ?: "Missing argument :("
            BottomSheet(
                showFeed = { navController.navigate(Destinations.Feed) },
                showAnotherSheet = {
                    navController.navigate(Destinations.Sheet + "?arg=${UUID.randomUUID()}")
                },
                arg = arg,
            )
        }
    }
}
Parameters
route: String

route for the destination

arguments: List<NamedNavArgument> = emptyList()

list of arguments to associate with destination

deepLinks: List<NavDeepLink> = emptyList()

list of deep links to associate with the destinations

content: @Composable ColumnScope.(backstackEntry: NavBackStackEntry) -> Unit

the sheet content at the given destination

inline fun Any> NavGraphBuilder.bottomSheet(
    typeMap: Map<KTypeNavType<*>> = emptyMap(),
    arguments: List<NamedNavArgument> = emptyList(),
    deepLinks: List<NavDeepLink> = emptyList(),
    noinline content: @Composable ColumnScope.(backstackEntry: NavBackStackEntry) -> Unit
): Unit

Add the content as bottom sheet content to the NavGraphBuilder

import androidx.compose.material.Text
import androidx.compose.material.navigation.ModalBottomSheetLayout
import androidx.compose.material.navigation.bottomSheet
import androidx.compose.material.navigation.rememberBottomSheetNavigator
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.rememberNavController

val bottomSheetNavigator = rememberBottomSheetNavigator()
val navController = rememberNavController(bottomSheetNavigator)

ModalBottomSheetLayout(bottomSheetNavigator) {
    NavHost(navController, Destinations.Home) {
        composable(Destinations.Home) {
            HomeScreen(
                showSheet = {
                    navController.navigate(Destinations.Sheet + "?arg=From Home Screen")
                },
                showFeed = { navController.navigate(Destinations.Feed) },
            )
        }
        composable(Destinations.Feed) { Text("Feed!") }
        bottomSheet(Destinations.Sheet + "?arg={arg}") { backstackEntry ->
            val arg = backstackEntry.arguments?.getString("arg") ?: "Missing argument :("
            BottomSheet(
                showFeed = { navController.navigate(Destinations.Feed) },
                showAnotherSheet = {
                    navController.navigate(Destinations.Sheet + "?arg=${UUID.randomUUID()}")
                },
                arg = arg,
            )
        }
    }
}
Parameters
Any>

route from a KClass for the destination

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.

arguments: List<NamedNavArgument> = emptyList()

list of arguments to associate with destination

deepLinks: List<NavDeepLink> = emptyList()

list of deep links to associate with the destinations

noinline content: @Composable ColumnScope.(backstackEntry: NavBackStackEntry) -> Unit

the sheet content at the given destination

fun NavGraphBuilder.composable(
    route: String,
    arguments: List<NamedNavArgument> = emptyList(),
    deepLinks: List<NavDeepLink> = emptyList(),
    content: @Composable (NavBackStackEntry) -> Unit
): Unit

Utility function for building Wear Compose navigation graphs.

Adds the content composable to the NavGraphBuilder as a WearNavigator.Destination.

Parameters
route: String

route for the destination

arguments: List<NamedNavArgument> = emptyList()

list of arguments to associate with destination

deepLinks: List<NavDeepLink> = emptyList()

list of deep links to associate with the destinations

content: @Composable (NavBackStackEntry) -> Unit

composable for the destination

inline fun Any> NavGraphBuilder.composable(
    typeMap: Map<KTypeNavType<*>> = emptyMap(),
    deepLinks: List<NavDeepLink> = emptyList(),
    noinline enterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = null,
    noinline exitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = null,
    noinline popEnterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = enterTransition,
    noinline popExitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = exitTransition,
    noinline sizeTransform: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> SizeTransform?)? = null,
    noinline content: @Composable AnimatedContentScope.(NavBackStackEntry) -> Unit
): Unit

Add the Composable to the NavGraphBuilder

Parameters
Any>

route from a KClass for the destination

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.

deepLinks: List<NavDeepLink> = emptyList()

list of deep links to associate with the destinations

noinline enterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = null

callback to determine the destination's enter transition

noinline exitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = null

callback to determine the destination's exit transition

noinline popEnterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = enterTransition

callback to determine the destination's popEnter transition

noinline popExitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = exitTransition

callback to determine the destination's popExit transition

noinline sizeTransform: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> SizeTransform?)? = null

callback to determine the destination's sizeTransform.

noinline content: @Composable AnimatedContentScope.(NavBackStackEntry) -> Unit

composable for the destination

fun Any> NavGraphBuilder.composable(
    route: KClass,
    typeMap: Map<KTypeNavType<*>> = emptyMap(),
    deepLinks: List<NavDeepLink> = emptyList(),
    enterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = null,
    exitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = null,
    popEnterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = enterTransition,
    popExitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = exitTransition,
    sizeTransform: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> SizeTransform?)? = null,
    content: @Composable AnimatedContentScope.(NavBackStackEntry) -> Unit
): Unit

Add the Composable to the NavGraphBuilder

Parameters
route: KClass

route from a KClass for the destination

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

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

deepLinks: List<NavDeepLink> = emptyList()

list of deep links to associate with the destinations

enterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = null

callback to determine the destination's enter transition

exitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = null

callback to determine the destination's exit transition

popEnterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = enterTransition

callback to determine the destination's popEnter transition

popExitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = exitTransition

callback to determine the destination's popExit transition

sizeTransform: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> SizeTransform?)? = null

callback to determine the destination's sizeTransform.

content: @Composable AnimatedContentScope.(NavBackStackEntry) -> Unit

composable for the destination

fun NavGraphBuilder.composable(
    route: String,
    arguments: List<NamedNavArgument> = emptyList(),
    deepLinks: List<NavDeepLink> = emptyList(),
    enterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = null,
    exitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = null,
    popEnterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = enterTransition,
    popExitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = exitTransition,
    sizeTransform: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> SizeTransform?)? = null,
    content: @Composable AnimatedContentScope.(NavBackStackEntry) -> Unit
): Unit

Add the Composable to the NavGraphBuilder

Parameters
route: String

route for the destination

arguments: List<NamedNavArgument> = emptyList()

list of arguments to associate with destination

deepLinks: List<NavDeepLink> = emptyList()

list of deep links to associate with the destinations

enterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = null

callback to determine the destination's enter transition

exitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = null

callback to determine the destination's exit transition

popEnterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = enterTransition

callback to determine the destination's popEnter transition

popExitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = exitTransition

callback to determine the destination's popExit transition

sizeTransform: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> SizeTransform?)? = null

callback to determine the destination's sizeTransform.

content: @Composable AnimatedContentScope.(NavBackStackEntry) -> Unit

composable for the destination

inline fun Any> NavGraphBuilder.dialog(
    typeMap: Map<KTypeNavType<*>> = emptyMap(),
    deepLinks: List<NavDeepLink> = emptyList(),
    dialogProperties: DialogProperties = DialogProperties(),
    noinline content: @Composable (NavBackStackEntry) -> Unit
): Unit

Add the Composable to the NavGraphBuilder that will be hosted within a androidx.compose.ui.window.Dialog. This is suitable only when this dialog represents a separate screen in your app that needs its own lifecycle and saved state, independent of any other destination in your navigation graph. For use cases such as AlertDialog, you should use those APIs directly in the composable destination that wants to show that dialog.

Parameters
Any>

route from a KClass for the destination

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.

deepLinks: List<NavDeepLink> = emptyList()

list of deep links to associate with the destinations

dialogProperties: DialogProperties = DialogProperties()

properties that should be passed to androidx.compose.ui.window.Dialog.

noinline content: @Composable (NavBackStackEntry) -> Unit

composable content for the destination that will be hosted within the Dialog

fun Any> NavGraphBuilder.dialog(
    route: KClass,
    typeMap: Map<KTypeNavType<*>> = emptyMap(),
    deepLinks: List<NavDeepLink> = emptyList(),
    dialogProperties: DialogProperties = DialogProperties(),
    content: @Composable (NavBackStackEntry) -> Unit
): Unit

Add the Composable to the NavGraphBuilder that will be hosted within a androidx.compose.ui.window.Dialog. This is suitable only when this dialog represents a separate screen in your app that needs its own lifecycle and saved state, independent of any other destination in your navigation graph. For use cases such as AlertDialog, you should use those APIs directly in the composable destination that wants to show that dialog.

Parameters
route: KClass

route from KClass of T for the destination

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

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

deepLinks: List<NavDeepLink> = emptyList()

list of deep links to associate with the destinations

dialogProperties: DialogProperties = DialogProperties()

properties that should be passed to androidx.compose.ui.window.Dialog.

content: @Composable (NavBackStackEntry) -> Unit

composable content for the destination that will be hosted within the Dialog

fun NavGraphBuilder.dialog(
    route: String,
    arguments: List<NamedNavArgument> = emptyList(),
    deepLinks: List<NavDeepLink> = emptyList(),
    dialogProperties: DialogProperties = DialogProperties(),
    content: @Composable (NavBackStackEntry) -> Unit
): Unit

Add the Composable to the NavGraphBuilder that will be hosted within a androidx.compose.ui.window.Dialog. This is suitable only when this dialog represents a separate screen in your app that needs its own lifecycle and saved state, independent of any other destination in your navigation graph. For use cases such as AlertDialog, you should use those APIs directly in the composable destination that wants to show that dialog.

Parameters
route: String

route for the destination

arguments: List<NamedNavArgument> = emptyList()

list of arguments to associate with destination

deepLinks: List<NavDeepLink> = emptyList()

list of deep links to associate with the destinations

dialogProperties: DialogProperties = DialogProperties()

properties that should be passed to androidx.compose.ui.window.Dialog.

content: @Composable (NavBackStackEntry) -> Unit

composable content for the destination that will be hosted within the Dialog

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

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

Construct a nested NavGraph

Parameters
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

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

Construct a nested NavGraph

Parameters
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

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

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

Construct a nested NavGraph

Parameters
route: KClass

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

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

Construct a nested NavGraph

Parameters
route: KClass

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

inline fun Any> NavGraphBuilder.navigation(
    startDestination: Any,
    typeMap: Map<KTypeNavType<*>> = emptyMap(),
    deepLinks: List<NavDeepLink> = emptyList(),
    noinline enterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = null,
    noinline exitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = null,
    noinline popEnterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = enterTransition,
    noinline popExitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = exitTransition,
    noinline sizeTransform: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> SizeTransform?)? = null,
    noinline builder: NavGraphBuilder.() -> Unit
): Unit

Construct a nested NavGraph

import androidx.compose.animation.EnterTransition
import androidx.compose.animation.ExitTransition
import androidx.compose.animation.SizeTransform
import androidx.compose.animation.core.keyframes
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.size
import androidx.compose.ui.unit.IntSize
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.rememberNavController

val navController = rememberNavController()
Box {
    NavHost(navController, startDestination = Collapsed) {
        composable(
            enterTransition = { EnterTransition.None },
            exitTransition = { ExitTransition.None },
            sizeTransform = {
                SizeTransform { initialSize, targetSize ->
                    keyframes {
                        durationMillis = 500
                        IntSize(
                            initialSize.width,
                            (initialSize.height + targetSize.height) / 2
                        ) at 150
                    }
                }
            }
        ) {
            CollapsedScreen { navController.navigate(Expanded) }
        }
        composable(
            enterTransition = { EnterTransition.None },
            exitTransition = { ExitTransition.None },
            sizeTransform = {
                SizeTransform { initialSize, targetSize ->
                    keyframes {
                        durationMillis = 500
                        IntSize(targetSize.width, initialSize.height + 400) at 150
                    }
                }
            }
        ) {
            ExpandedScreen { navController.popBackStack() }
        }
    }
}
Parameters
Any>

the destination's unique route from a KClass

startDestination: Any

the starting destination's route from an Object for this NavGraph

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.

deepLinks: List<NavDeepLink> = emptyList()

list of deep links to associate with the destinations

noinline enterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = null

callback to define enter transitions for destination in this NavGraph

noinline exitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = null

callback to define exit transitions for destination in this NavGraph

noinline popEnterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = enterTransition

callback to define pop enter transitions for destination in this NavGraph

noinline popExitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = exitTransition

callback to define pop exit transitions for destination in this NavGraph

noinline sizeTransform: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> SizeTransform?)? = null

callback to define the size transform for destinations in this NavGraph

noinline builder: NavGraphBuilder.() -> Unit

the builder used to construct the graph

Returns
Unit

the newly constructed nested NavGraph

inline fun Any> NavGraphBuilder.navigation(
    startDestination: KClass<*>,
    typeMap: Map<KTypeNavType<*>> = emptyMap(),
    deepLinks: List<NavDeepLink> = emptyList(),
    noinline enterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = null,
    noinline exitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = null,
    noinline popEnterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = enterTransition,
    noinline popExitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = exitTransition,
    noinline sizeTransform: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> SizeTransform?)? = null,
    noinline builder: NavGraphBuilder.() -> Unit
): Unit

Construct a nested NavGraph

import androidx.compose.animation.EnterTransition
import androidx.compose.animation.ExitTransition
import androidx.compose.animation.SizeTransform
import androidx.compose.animation.core.keyframes
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.size
import androidx.compose.ui.unit.IntSize
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.rememberNavController

val navController = rememberNavController()
Box {
    NavHost(navController, startDestination = Collapsed) {
        composable(
            enterTransition = { EnterTransition.None },
            exitTransition = { ExitTransition.None },
            sizeTransform = {
                SizeTransform { initialSize, targetSize ->
                    keyframes {
                        durationMillis = 500
                        IntSize(
                            initialSize.width,
                            (initialSize.height + targetSize.height) / 2
                        ) at 150
                    }
                }
            }
        ) {
            CollapsedScreen { navController.navigate(Expanded) }
        }
        composable(
            enterTransition = { EnterTransition.None },
            exitTransition = { ExitTransition.None },
            sizeTransform = {
                SizeTransform { initialSize, targetSize ->
                    keyframes {
                        durationMillis = 500
                        IntSize(targetSize.width, initialSize.height + 400) at 150
                    }
                }
            }
        ) {
            ExpandedScreen { navController.popBackStack() }
        }
    }
}
Parameters
Any>

the destination's unique route from a KClass

startDestination: KClass<*>

the starting destination's route from KClass for this NavGraph

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.

deepLinks: List<NavDeepLink> = emptyList()

list of deep links to associate with the destinations

noinline enterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = null

callback to define enter transitions for destination in this NavGraph

noinline exitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = null

callback to define exit transitions for destination in this NavGraph

noinline popEnterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = enterTransition

callback to define pop enter transitions for destination in this NavGraph

noinline popExitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = exitTransition

callback to define pop exit transitions for destination in this NavGraph

noinline sizeTransform: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> SizeTransform?)? = null

callback to define the size transform for destinations in this NavGraph

noinline builder: NavGraphBuilder.() -> Unit

the builder used to construct the graph

Returns
Unit

the newly constructed nested NavGraph

fun Any> NavGraphBuilder.navigation(
    startDestination: Any,
    route: KClass,
    typeMap: Map<KTypeNavType<*>> = emptyMap(),
    deepLinks: List<NavDeepLink> = emptyList(),
    enterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = null,
    exitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = null,
    popEnterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = enterTransition,
    popExitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = exitTransition,
    sizeTransform: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> SizeTransform?)? = null,
    builder: NavGraphBuilder.() -> Unit
): Unit

Construct a nested NavGraph

import androidx.compose.animation.EnterTransition
import androidx.compose.animation.ExitTransition
import androidx.compose.animation.SizeTransform
import androidx.compose.animation.core.keyframes
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.size
import androidx.compose.ui.unit.IntSize
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.rememberNavController

val navController = rememberNavController()
Box {
    NavHost(navController, startDestination = Collapsed) {
        composable(
            enterTransition = { EnterTransition.None },
            exitTransition = { ExitTransition.None },
            sizeTransform = {
                SizeTransform { initialSize, targetSize ->
                    keyframes {
                        durationMillis = 500
                        IntSize(
                            initialSize.width,
                            (initialSize.height + targetSize.height) / 2
                        ) at 150
                    }
                }
            }
        ) {
            CollapsedScreen { navController.navigate(Expanded) }
        }
        composable(
            enterTransition = { EnterTransition.None },
            exitTransition = { ExitTransition.None },
            sizeTransform = {
                SizeTransform { initialSize, targetSize ->
                    keyframes {
                        durationMillis = 500
                        IntSize(targetSize.width, initialSize.height + 400) at 150
                    }
                }
            }
        ) {
            ExpandedScreen { navController.popBackStack() }
        }
    }
}
Parameters
startDestination: Any

the starting destination's route from an Object for this NavGraph

route: KClass

the 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 route does not use custom NavTypes.

deepLinks: List<NavDeepLink> = emptyList()

list of deep links to associate with the destinations

enterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = null

callback to define enter transitions for destination in this NavGraph

exitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = null

callback to define exit transitions for destination in this NavGraph

popEnterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = enterTransition

callback to define pop enter transitions for destination in this NavGraph

popExitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = exitTransition

callback to define pop exit transitions for destination in this NavGraph

sizeTransform: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> SizeTransform?)? = null

callback to define the size transform for destinations in this NavGraph

builder: NavGraphBuilder.() -> Unit

the builder used to construct the graph

Returns
Unit

the newly constructed nested NavGraph

fun Any> NavGraphBuilder.navigation(
    startDestination: KClass<*>,
    route: KClass,
    typeMap: Map<KTypeNavType<*>> = emptyMap(),
    deepLinks: List<NavDeepLink> = emptyList(),
    enterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = null,
    exitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = null,
    popEnterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = enterTransition,
    popExitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = exitTransition,
    sizeTransform: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> SizeTransform?)? = null,
    builder: NavGraphBuilder.() -> Unit
): Unit

Construct a nested NavGraph

import androidx.compose.animation.EnterTransition
import androidx.compose.animation.ExitTransition
import androidx.compose.animation.SizeTransform
import androidx.compose.animation.core.keyframes
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.size
import androidx.compose.ui.unit.IntSize
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.rememberNavController

val navController = rememberNavController()
Box {
    NavHost(navController, startDestination = Collapsed) {
        composable(
            enterTransition = { EnterTransition.None },
            exitTransition = { ExitTransition.None },
            sizeTransform = {
                SizeTransform { initialSize, targetSize ->
                    keyframes {
                        durationMillis = 500
                        IntSize(
                            initialSize.width,
                            (initialSize.height + targetSize.height) / 2
                        ) at 150
                    }
                }
            }
        ) {
            CollapsedScreen { navController.navigate(Expanded) }
        }
        composable(
            enterTransition = { EnterTransition.None },
            exitTransition = { ExitTransition.None },
            sizeTransform = {
                SizeTransform { initialSize, targetSize ->
                    keyframes {
                        durationMillis = 500
                        IntSize(targetSize.width, initialSize.height + 400) at 150
                    }
                }
            }
        ) {
            ExpandedScreen { navController.popBackStack() }
        }
    }
}
Parameters
startDestination: KClass<*>

the starting destination's route from KClass for this NavGraph

route: KClass

the 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 route does not use custom NavTypes.

deepLinks: List<NavDeepLink> = emptyList()

list of deep links to associate with the destinations

enterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = null

callback to define enter transitions for destination in this NavGraph

exitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = null

callback to define exit transitions for destination in this NavGraph

popEnterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = enterTransition

callback to define pop enter transitions for destination in this NavGraph

popExitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = exitTransition

callback to define pop exit transitions for destination in this NavGraph

sizeTransform: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> SizeTransform?)? = null

callback to define the size transform for destinations in this NavGraph

builder: NavGraphBuilder.() -> Unit

the builder used to construct the graph

Returns
Unit

the newly constructed nested NavGraph

fun NavGraphBuilder.navigation(
    startDestination: String,
    route: String,
    arguments: List<NamedNavArgument> = emptyList(),
    deepLinks: List<NavDeepLink> = emptyList(),
    enterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = null,
    exitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = null,
    popEnterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = enterTransition,
    popExitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = exitTransition,
    sizeTransform: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> SizeTransform?)? = null,
    builder: NavGraphBuilder.() -> Unit
): Unit

Construct a nested NavGraph

import androidx.compose.animation.EnterTransition
import androidx.compose.animation.ExitTransition
import androidx.compose.animation.SizeTransform
import androidx.compose.animation.core.keyframes
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.size
import androidx.compose.ui.unit.IntSize
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.rememberNavController

val navController = rememberNavController()
Box {
    NavHost(navController, startDestination = Collapsed) {
        composable(
            enterTransition = { EnterTransition.None },
            exitTransition = { ExitTransition.None },
            sizeTransform = {
                SizeTransform { initialSize, targetSize ->
                    keyframes {
                        durationMillis = 500
                        IntSize(
                            initialSize.width,
                            (initialSize.height + targetSize.height) / 2
                        ) at 150
                    }
                }
            }
        ) {
            CollapsedScreen { navController.navigate(Expanded) }
        }
        composable(
            enterTransition = { EnterTransition.None },
            exitTransition = { ExitTransition.None },
            sizeTransform = {
                SizeTransform { initialSize, targetSize ->
                    keyframes {
                        durationMillis = 500
                        IntSize(targetSize.width, initialSize.height + 400) at 150
                    }
                }
            }
        ) {
            ExpandedScreen { navController.popBackStack() }
        }
    }
}
Parameters
startDestination: String

the starting destination's route for this NavGraph

route: String

the destination's unique route

arguments: List<NamedNavArgument> = emptyList()

list of arguments to associate with destination

deepLinks: List<NavDeepLink> = emptyList()

list of deep links to associate with the destinations

enterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = null

callback to define enter transitions for destination in this NavGraph

exitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = null

callback to define exit transitions for destination in this NavGraph

popEnterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition?)? = enterTransition

callback to define pop enter transitions for destination in this NavGraph

popExitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition?)? = exitTransition

callback to define pop exit transitions for destination in this NavGraph

sizeTransform: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> SizeTransform?)? = null

callback to define the size transform for destinations in this NavGraph

builder: NavGraphBuilder.() -> Unit

the builder used to construct the graph

Returns
Unit

the newly constructed nested NavGraph