Please if you have time, have a look at this issue...
# compose
c
Please if you have time, have a look at this issue.
Copy code
type = NavType.IntArrayType
I’m getting this crash because IntArray is not supported. Funny enough I should be using ArrayList<Int> This is really not intuitive, or am I not being intuitive? haha
i
Neither are supported when parsing from a route, so you shouldn't be using either as part of arguments in your route
c
aha
yea, just found out it’s crashing too
What should I use if I wanna pass a list of integers?
i
You shouldn't be passing a list of integers at all. Can you explain your use case and why you're trying to pass large amounts of data through a route?
c
not really large, my user will be selecting a group of options, and depending on the options he selected I want to present a set of articles informing him about how to proceed depending on the selection. So, somehow, I need to know this selections to present the data in the next screen
i
Think about it this way: a route is like a web URL - it points to a specific screen in your app, uniquely identifying it. If you were building a website, how would you write that URL? Would you really pass that information as part of the URL? Maybe as one or more query parameters? Or would you have saved that information into a shared Request Repository that one destination can write to and the other read from. Then you'd only pass the ID of the request
c
It’s not the kind of information I would like to save somewhere. I thought about it, I actually do this in another project. But it would definitely make sense to send this list of indexes in this particular case. If this would be a website it would be a query, but this specific query and because of the way this data is organized, it would need this individual indexs to understand what to show in the next view
and if it was like a URL I would be able to assemble this query where in this particular case my view is not really aware of the navigation component and wouldn’t be able change this navigation argument
Copy code
composable(
    Route.toResults,
    arguments = listOf(
        navArgument("selectedIds") {
            type = NavType.IntArrayType
        }
    )
)
I could actually make it a string and break it down
Bottom line is I need to do this the way you planned to and I can’t do it in a simpler way which would solve my problem because you think that’s not a good ideia. Besides all the beautiful explanation of how I should solve my problem, why can’t I do it the other way? I don’t believe that there would be a technical restriction on the amount of memory needed to pass around a list of indexes, I can’t believe this restriction is healthy at all. And how do I change this? Can I submit a pr or something?
i
This will never change. You should model your data differently
There's nothing saying you have to pass arguments directly to your Composable though - you can do whatever pre-processing into an IntArray as you want
c
Yea, I’m going to have this indexes in a string and I’m gonna transform them into the list of integers, which is ridiculous. I can see the why but I can’t see the why the other way wouldn’t also be possible
I mean, why would this be possible?
Copy code
arguments = listOf(
    navArgument("selectedComplicationsIds") {
        type = NavType.IntArrayType
    }
It took me like 3h of messing around to be able to formulate a question and I could just have had and error like: “This data format is not suported”
Just kind of frustrating
I mean, I had this in the unpacking but I thought I did something wrong 😞
i
https://issuetracker.google.com/issues/182194894 tracks updating the documentation to clarify which types can be parsed from deep links / routes
Those types are supported for default values and do have legit use cases as arguments...just not as arguments which are part of your route
c
Aha
Because I noticed the system was using it which ended up confusing
Thank you for the patience Mr. Lake