In one of my view models, I have this code:
var days = mutableStateListOf(
Cell("Sun", false),
Cell("Mon", false),
Cell("Tue", false),
Cell("Wed", false),
Cell("Thu", false),
Cell("Fri", false),
Cell("Sat", false)
)
And I have this function to change the boolean in a Cell:
fun changeDaySelection(index: Int) {
// days[index].isSelected = !days[index].isSelected <- this line does cause recomposition
days[index] = Cell(days[index].text, !days[index].isSelected) // <- this line does cause recomposition
}
Not entirely sure why the commented line wouldn't work