androidx.navigation.compose
Classes
ComposeNavigator |
Navigator that navigates through Composables. |
NamedNavArgument |
Construct a named NavArgument by using the navArgument method. |
Top-level constants summary
const String |
The route linked to the current destination. |
Top-level functions summary
Unit |
NavHost(: NavHostController, : String, : String? = null, : NavGraphBuilder.() -> Unit) Provides in place in the Compose hierarchy for self contained navigation to occur. |
Unit |
NavHost(: NavHostController, : NavGraph) Provides in place in the Compose hierarchy for self contained navigation to occur. |
NamedNavArgument |
navArgument(: String, : NavArgumentBuilder.() -> Unit) Construct a new NavArgument |
NavHostController |
Creates a NavHostController that handles the adding of the ComposeNavigator. |
Extension functions summary
For NavGraphBuilder | |
Unit |
NavGraphBuilder.composable(: String, : List<NamedNavArgument> = emptyList(), : List<NavDeepLink> = emptyList(), : (NavBackStackEntry) -> Unit) Add the Composable to the NavGraphBuilder |
Unit |
NavGraphBuilder.navigation(: String, : String, : NavGraphBuilder.() -> Unit) Construct a nested NavGraph |
For NavController | |
NavGraph |
NavController.createGraph(: String, : String? = null, : NavGraphBuilder.() -> Unit) Construct a new NavGraph |
State<NavBackStackEntry?> |
Gets the current navigation back stack entry as a MutableState. |
Unit |
NavController.navigate(: String, : NavOptionsBuilder.() -> Unit = {}) Navigate to a route in the current NavGraph. |
For NavOptionsBuilder | |
Unit |
NavOptionsBuilder.popUpTo(: String, : PopUpToBuilder.() -> Unit) Pop up to a given destination before navigating. |
Top-level constants
KEY_ROUTE
const val KEY_ROUTE: String
The route linked to the current destination.
Value: "android-support-nav:controller:route"
Top-level functions
NavHost
@Composable fun NavHost(
: NavHostController,
: String,
: String? = null,
: NavGraphBuilder.() -> Unit
): Unit
Provides in place in the Compose hierarchy for self contained navigation to occur.
Once this is called, any Composable within the given NavGraphBuilder can be navigated to from the provided navController.
The builder passed into this method is remembered. This means that for this NavHost, the contents of the builder cannot be changed.
import androidx.navigation.compose.NavHost import androidx.navigation.compose.composable import androidx.navigation.compose.rememberNavController val navController = rememberNavController() NavHost(navController, startDestination = Screen.Profile.route) { composable(Screen.Profile.route) { Profile(navController) } composable(Screen.Dashboard.route) { Dashboard(navController) } composable(Screen.Scrollable.route) { Scrollable(navController) } }
Parameters | |
---|---|
: NavHostController | the navController for this host |
: String | the route for the start destination |
: String? = null | the route for the graph |
: NavGraphBuilder.() -> Unit | the builder used to construct the graph |
NavHost
@Composable fun NavHost(
: NavHostController,
: NavGraph
): Unit
Provides in place in the Compose hierarchy for self contained navigation to occur.
Once this is called, any Composable within the given NavGraphBuilder can be navigated to from the provided navController.
The graph passed into this method is remembered. This means that for this NavHost, the graph cannot be changed.
Parameters | |
---|---|
: NavHostController | the navController for this host |
: NavGraph | the graph for this host |
navArgument
fun navArgument(
: String,
: NavArgumentBuilder.() -> Unit
): NamedNavArgument
Construct a new NavArgument
rememberNavController
@Composable fun rememberNavController(): NavHostController
Creates a NavHostController that handles the adding of the ComposeNavigator.
See Also
Extension functions
composable
fun NavGraphBuilder.composable(
: String,
: List<NamedNavArgument> = emptyList(),
: List<NavDeepLink> = emptyList(),
: (NavBackStackEntry) -> Unit
): Unit
Add the Composable to the NavGraphBuilder
Parameters | |
---|---|
: String | route for the destination |
: List<NamedNavArgument> = emptyList() | list of arguments to associate with destination |
: List<NavDeepLink> = emptyList() | list of deep links to associate with the destinations |
: (NavBackStackEntry) -> Unit | composable for the destination |