I have `LazyVerticalGrid` with `itemsIndexed` over...
# compose
o
I have
LazyVerticalGrid
with
itemsIndexed
over a property which is
mutableStateListOf
. Everything is working fine when I add items, but when I remove items via
remove
or
clear
on that list I get an exception trying to access non-existing items. It’s a call from inside the
itemsIndexed
, looks like it didn’t notice collection has changed. Is it a known issue or am I doing something wrong?
Same with
items
The code is pretty trivial
Copy code
LazyVerticalGrid(GridCells.Adaptive(72.dp)) {
            itemsIndexed(inventory.items) { index, it ->
                Text("${it.thing.name} [${it.amount}]")
            }
        }
and
Copy code
class Inventory() {
    val items = mutableStateListOf<InventoryItem>()
Exception
d
Yeah I've seen this exception in Slack a couple times.
o
I see, thanks. @Andrey Kulikov is it yours? 🙂
Reproducable with desktop compose 0.3.0-rc1, not sure which compose is bundled
a
hey! yes, sorry it is not yet fixed, but I have plan to fix it in upcomming releases. please consider using mutableStateOf immutable lists for now
l
Is there a public issue to follow?
a
o
Yes, I’m using mutable state of immutable list now, it works fine. Thanks.
I see this issue is marked as fixed, but how do I know if it were already released in some public build? And if it also went to compose-desktop?
a
it was released in beta02 of the android build and in the first desktop release created after 3th of March(basically the latest one should contain it)
l
It'd be so nice that Google's issue tracker shows in a public metadata-field what releases will first include a given fix.
1