orangy
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?orangy
items
orangy
LazyVerticalGrid(GridCells.Adaptive(72.dp)) {
itemsIndexed(inventory.items) { index, it ->
Text("${it.thing.name} [${it.amount}]")
}
}
and
class Inventory() {
val items = mutableStateListOf<InventoryItem>()
orangy
Dominaezzz
02/21/2021, 1:39 PMDominaezzz
02/21/2021, 1:42 PMorangy
orangy
Andrey Kulikov
02/21/2021, 2:49 PMlouiscad
02/21/2021, 2:51 PMAndrey Kulikov
02/21/2021, 2:51 PMorangy
orangy
Andrey Kulikov
03/21/2021, 7:32 PMlouiscad
03/21/2021, 9:09 PM