Hi all, from the doc `<https://developer.android.c...
# compose
b
Hi all, from the doc
<https://developer.android.com/guide/navigation/navigation-pass-data#supported_argument_types>
navigation can accept a nullable string as parameter. Should we ignore the null argument ?
Copy code
composable(route = "person/{id}") {
            val id = it.arguments?.getString("id") // here i am getting the word `null` as as string instead of String? = null 
        }
        navController.navigate("person/${null}")
i
If you navigate to
person/null
, you will get the ID of
null
, just like you said it should be; there's no string interpretation being done for path parameters (which are always required parameters). Optional arguments are in the form of query parameters (where what you'd navigate to is
person
, which would match a route of `person?id={id}`: https://developer.android.com/jetpack/compose/navigation#optional-args
b
so basically i need to pass them as optional parameters and set them as nullable = true ?
i
that's exactly what the section labeled "Adding optional arguments" says, yes
1