Skip to content

Instantly share code, notes, and snippets.

@k0siara
Last active February 12, 2022 18:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save k0siara/1359a9831a34d364a5733240cae3ac45 to your computer and use it in GitHub Desktop.
Save k0siara/1359a9831a34d364a5733240cae3ac45 to your computer and use it in GitHub Desktop.
ExampleNavHostWithCustomNavType.kt
NavHost(...) {
composable("home") {
Home(
onClick = {
val example = Example("1", "Example")
val json = Uri.encode(Gson().toJson(example))
navController.navigate("details/$json")
}
)
}
composable(
"details/{example}",
arguments = listOf(
navArgument("example") {
type = ExampleNavType()
}
)
) {
val example = it.arguments?.getParcelable<Example>("example")
Details(example)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment