Using the new navigation for Compose, can I use `P...
# compose
g
Using the new navigation for Compose, can I use
Parcelable
arguments or is it only uri-based arguments that can be parse to primitive types?
g
as I understand it it's meant to be used as uri like arguments
g
sigh.... Thanks 👍
i
Yes, that's correct
j
I was trying without success to pass a parcelable and found this. But then, if we need to do a simple two-screens list-detail we will need to find a way to scope an object that holds the list and lives for both screens (but not more to save memory). For simple cases this is quite cumbersome compared to just passing a parcelable
g
I have a list of them in the viewmodel and just get the item from that list when moving to the details screen
Copy code
composable(Screen.ImageItem.route + "?imageId={imageId}") { backStackEntry ->
	val imageId = backStackEntry.arguments?.getString("imageId")
	val imageItems by viewModel.imageItems.collectAsState()
	ImageItemScreen(imageItems.first { it.id == imageId })
}
i
The better thread about this, with more information on how routes should be treated re: Parcelables is https://kotlinlang.slack.com/archives/CJLTWPH7S/p1604053414451400