Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
NavHostNavigationExample.kt
@Composable
fun NavHostExample() {
val navController = rememberNavController()
NavHost(navController, startDestination = "firstScreen") {
composable(route = "firstScreen") {
FirstScreen(navController)
}
composable(route = "secondScreen") {
SecondScreen()
}
}
}
@Composable
fun FirstScreen(navController: NavController) {
Scaffold {
Button(onClick = {
navController.navigate("secondScreen")
}) {
Text("Navigate to second screen")
}
}
}
@Composable
fun SecondScreen(...) { ... }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment