Colton Idle
10/21/2024, 12:02 AMItem
in that list could also have a checkmark next to it to show that it's selected.
What's the go-to?
Option 1:
var todos = mutableStateListOf<Pair<Item, Boolean>>()
Option 2:
var todos = mutableStateListOf<Item>()
class Item(
val id: Int,
// other stuff
var selected by mutableStateOf(false),
)
Option 3:
var todos = mutableStateListOf<Item>()
and make Item a data class so that I can copy it?Sterling Albury
10/21/2024, 12:43 AMItem
to be immutable.
class Item(val id: Int, val name: String)
var todos = mutableStateListOf<Item>()
var selectedTodos = mutableStateListOf<Int>()
not sure if you want to keep selected
as a field on Item
but you could persist the selected items separately as just the IDs of the items.Colton Idle
10/21/2024, 3:02 AM