Saurav Suman
02/17/2023, 10:48 AM<https://stackoverflow.com/questions/74381205/removing-item-from-the-list-causes-wrong-display-in-lazycolumn>
abbic
02/17/2023, 11:33 AMitems
callback to be associated with a key. that way, when an item is removed, the LazyColumn knows what is removed.
In that example, say each Person
had a field called id, which was unique to it.
Then you'd write
items(people.size, key = { index -> people[index].id }) { etc ...
Saurav Suman
02/17/2023, 11:34 AMabbic
02/17/2023, 11:34 AMkey
function associates an index with an id, so when an item is removed and all the indices of the items change, the key callback now reconnects the index to the item it should contain properlySaurav Suman
02/17/2023, 11:35 AMabbic
02/17/2023, 11:36 AMSaurav Suman
02/17/2023, 11:36 AM