What is the right way to deep link into a destinat...
# compose
a
What is the right way to deep link into a destination in which its graph’s start destination has arguments. Should I pass those arguments to my deep link? Please see example in thread. I’m having an issue where I’m not able to navigate to the destination because of the missing parameters for the start destination.
Copy code
NavHost(
  ...,
  route = "navHost",
  startDestination = "a/{x}?{y}={y}",
) {
  composable(
     "a/{x}?y={y}",
     arguments = listOf(
       navArgument("y") { type = NavType.Long } 
     )
   ) {

  }
  composable("b") {
  }
}

navController.navigate("b")
i
If
x
is optional, it should be a query parameter (i.e.,
argName={x}
) otherwise it sounds like you should be adding a
defaultValue
to your
navArgument
👍 1
👋 1
a
Yes, I put both required and optional argument in the example. I see, for required arguments,
defaultValue
could be an option. Is there a way to specify a specific value to it when navigating to a non-start-destination? For example I want to go to
b
and when pressing back, I expect destination
a/x_value
But I’m getting the issue on the optional
{y}
actually, I get a “cannot cast null as Long”. Is it a bug?
i
{y}={y}
doesn't make any sense, FWIW - it should be
y={y}
if anything