UPDATE: This only happens in the intractable previ...
# compose
m
UPDATE: This only happens in the intractable preview, not on an actual device. I spent way too long messing with this before trying that 🤦‍♂️ Im running into a weird issue with
mutableStateListOf
and
Checkbox
that I’m pretty sure is a bug with Checkbox, was wondering if anyone has run into this and found a good workaround. So i have a Column of
CheckBoxes
and I’m using a
SnapshotStateList<Boolean>
to track the checked state of all the checkboxes. For some reason any checkbox that starts with
checked=true
works fine but if the initial value is false then its stuck in this weird in sort of disabled state and doesnt change despite the state updating. Heres a code snippet
Copy code
@Composable
fun CheckList() {
    val checked: MutableList<Boolean> = remember {
        mutableStateListOf(false, false, true, false, true, true, false)
    }

    Column {
        (0..6).forEach { index ->
            Row(verticalAlignment = Alignment.CenterVertically) {
                // Only the ones that start true work right
                Checkbox(checked = checked[index], onCheckedChange = { checked[index] = it })
                // The color of these update as expected when the checkbox is clicked so the state is updating properly 
                Icon(
                    Icons.Default.CheckCircle,
                    contentDescription = null,
                    tint = if (checked[index]) Color.Black else Color.Red
                )
            }
        }
    }
}
Heres a screengrab of the behavior
c
Looks like you have a good small repro of the behavior. Id file a bug for the team!