In this article it says that if the argument type of a composable is ImmutableList, it is considered as stable , meaning that if the list didn't change , the composable wont be recomposed .
@Immutable
data class Contact(val name: String, val age: Int)
@Composable
fun ContactRow(contacts: ImmutableList<Contact>, modifier: Modifier = Modifier) {
var selected by remember { mutableStateOf(false) }
Row(modifier) {
ContactDetails(contacts)
Checkbox(selected, onCheckedChange = {
selected = !selected
})
}
}
@Composable
fun ContactDetails(contacts: ImmutableList<Contact>) {
Text(text = contacts[0].name)
}
Here everytime i select the checkbox , the ContactDetails composable is recomposed , even though I am using ImmutableList from KotlinX collections.
My compose version is also 1.2.0


