Hey guys, does anyone know why my setup is crashin...
# compose
l
Hey guys, does anyone know why my setup is crashing? I have a compose navigation and one of the destinations is defined as such
Copy code
@Serializable
data class ItemDetail(val id: String)
When I call:
navController.navigate(ItemDetail("vghkj"))
or any other "non empty" text, it works flawlessly. But if I call it with an empty string, it crashes with this:
Copy code
java.lang.IllegalArgumentException: Navigation destination that matches request NavDeepLinkRequest{ uri=<android-app://androidx.navigation/com.example.app.ui.item.detail.ItemDetail/> } cannot be found in the navigation graph ComposeNavGraph(0x0) startDestination={ComposeNavGraph(0x6482f8f) route=com.example.app.app.MainGraph startDestination={Destination(0x2d4021c) route=com.example.app.loading.LoadingRoute}}
I am suspecting it might be a bug inside the compose navigation that incorrectly serializes the route, therefore it can't find the proper "deeplink", but not sure about this. It's an edge case, but I'd like to know if I can do something (besides putting garbage data into the data class so it never becomes empty), to prevent this from happening. Also I am on the newest compose multiplatform 1.7.0-alpha02 with navigation 2.8.0-alpha08
i
2.8.0-alpha08 is based on Google's 2.8.0-beta03 I believe it's fixed in 2.8.0-beta04
• Navigation now supports navigating with empty strings in path arguments. (Ic5dbd, b/339481310)
I'll plan to do another round of merges and pickup changes from Google's 2.8.0-beta06
❤️ 1
🦜 1
l
That would be very helpful, thanks
s
Does this fix now mean that one can navigate with a an empty string, and then you'd just get an empty string on the other side? And the url itself at some point would look like
something//1
for a pattern like
something/{someString}/{someNumber}
If you pass
""
and
1
?
l
That would be the expected situation in my opinion
i
It seems so. You can look at test cases that added with this fix by the link I posted above
thank you color 1