https://developer.android.com/jetpack/compose/navigation#optional-args
been going through documentation to figure out how to use multiple optional arguments and how to pass them
but in docs only one param is mentioned.
composable(
"profile?userId={userId}",
arguments = listOf(navArgument("userId") { defaultValue = "me" })
)
and call it with
composable("profile")
composable("profile/user123") // if you want to pass param
how to declare and call for two params ?
how to declare ?
composable(
"profile?userId={userId}&userType={userType}",
arguments = listOf(
navArgument("userType") {
defaultValue = "ADMIN"
type = NavType.StringType
}, navArgument("userId") {
nullable = true
defaultValue = null
type = NavType.StringType
})
)
how to call ?
navController.navigate("profile?userId=user123&userType=user")
navController.navigate("profile?userType=user")
navController.navigate("profile")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With