I'm having trouble finding if using a data class i...
# compose
c
I'm having trouble finding if using a data class is supported as the start destination of a graph in the safeargs compose navigation framework. Currently it crashes saying the class isn't serializable even though it's marked as such. I assume this means it's not supported... but if that's the case what's the recommended approach for needing to pass arguments to the start of your graph? Edit: Solved in đź§µ
Needed to make sure when I was calling that data class I was creating an instance of the data class instead of trying to refer to it as an object 🤦‍♂️ So instead of
navController.navigate(News.Home)
it needed to be
navController.navigate(News.Home())
🎣 1
p
Good catch 🎣
thank you color 1
c
Good video I stumbled across finally that helped me figure it out

https://www.youtube.com/watch?v=8m1W4PyYMYQâ–ľ

👍 1
i
FWIW, we should be throwing a Lint error for this case, specifically telling you it should be an instance of the class: https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:navigati[…]idx/navigation/runtime/lint/WrongNavigateRouteDetectorTest.kt
👍 1
thank you color 1
Please file an issue if that Lint check isn't firing for you: https://issuetracker.google.com/issues/new?component=409828&template=1093757
a
It’s happened to me also in generated code from an internal code generator library. It would be awesome if kotlin introduced a way to enforce “@Serializable” as part of the type . Like navigate(route: @Serializable Any) Enforces the type passed in applies the serializable annotation
âž• 1
i
If you file something on YouTrack, please include a link to it here
👍 1