79548894

Date: 2025-04-01 18:34:05
Score: 2
Natty:
Report link

Keep your list outside a composable so you have access to it everywhere. Preferably inside a ViewModel.

val items = mutableStateListOf<TodoItem>()

mutableStateListOf does have addAll(), so no need to use apply() .

Update the item the same way, but always check if the index is valid.

val index = items.indexOfFirst { it.id == item.id }
if (index != -1) {
    items[index] = items[index].copy(urgent = it)
}

Also remember to add a key to your LazyColumn so it actually updates properly.

items(items, key = { it.id }) {
    //content here
}
Reasons:
  • RegEx Blacklisted phrase (2): urgent
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: NobilityDev