Jetpack Compose Navigation

Source URL: https://stackoverflow.com/questions/59620988/how-to-handle-navigation-in-jetpack-compose

Language: whatever

Created on: 2021-10-03 18:29:13

val navController = rememberNavController()

NavHost(navController, startDestination = "profile") {
    composable("profile") { Profile(...) }
    composable("friendslist") { FriendsList(...) }
    ...
}

fun Profile(navController: NavController) {
    ...
    Button(onClick = { navController.navigate("friends") }) {
        Text(text = "Navigate next")
    }
    ...
}
In Jetpack Compose, how is navigation supposed to be done? All (and there aren’t many) examples (including the official sample from Google) use sealed classes and loading new screens in reaction to
content_copy