Honestly there is no much to share simply change C...
# compose
m
Honestly there is no much to share simply change Checkbox keyword for Switch....
Copy code
Row(Modifier.padding(5.dp)) {
    Text("Selected")
    //Switch(checked = lselected, onCheckedChange = { lselected = !lselected} )
    Checkbox(checked = lselected, onCheckedChange = { lselected = !lselected} )
    Text("Unselected")
}
y
Can you share the declaration of
lselected
too please?
m
It's a know issue as now Switch invokes
onCheckChange
after initial composition with the same value that you set in the Switch. For what it worth, the more correct handling of the callback would be
onCheckedChange = { lselected = it }
as switch already gives you the hint about to which state it wants to change
If you change it like this -- there will be no oscillation
m
Thank you so much, still both components checkbox and switch should work equally I guess ... some day .. in the future
m
Could you please clarify what you mean by "equally"? What's the difference between Checkbox and Switch behaviour that you see aside from that bug?
m
Jesus I don't want to argue at all, I'm quite satisfied, and I don't see any difference aside from that bug. I swear it!
😎 1
🤔 6
m
Sorry if I sounded rude, I didn't mean it. Thanks for your report and if you will find anything unusual or unpredictable about selection controls in the future -- please do let me know 🙂