MBegemot
09/09/2020, 9:45 AMvar lselected by mutableStateOf(true)
But again if it's a checkbox it's fine ...You can see the issue by clicking on settings languages +languagesYann Badoual
09/09/2020, 10:03 AMvar lselected by remember { mutableStateOf(true) }
?Yann Badoual
09/09/2020, 10:05 AMimport androidx.compose.runtime.getValue
import androidx.compose.runtime.setValue
MBegemot
09/09/2020, 10:07 AMTimo Drick
09/09/2020, 10:46 AMMBegemot
09/09/2020, 11:21 AMTimo Drick
09/09/2020, 2:21 PMMBegemot
09/09/2020, 3:25 PMonCheckedChange = { lselected = it}
and then it works. Still I see your point regarding remember, but in practice it is still from me unclear where I shall absolutely use it or not (remember), so my rule of thumb is right know use mutablestateof and if doesn't work try remember. And well that's all I can remember ....but slowly but constantly thinks are being settled and compose has very very much improved over timeYann Badoual
09/09/2020, 3:30 PMonDraw
call, you'd re-create the objects each time the view is drawn, this is not what you want here.Timo Drick
09/09/2020, 3:30 PMval v by remember { mutableStateOf(..) }
Timo Drick
09/09/2020, 3:35 PMMBegemot
09/09/2020, 3:44 PMTimo Drick
09/10/2020, 9:59 AM@MBegemot
really don't need remember at all, in fact using it or not it makes no
difference , someone answered that there's a bug and you should write
onCheckedChange = { lselected = it}It is not a bug in Checkbox. This is the correct behavior. Because in compose the components do not have a state. And the onCheckedChange callback just tell you that the user wants a new state. So you need to forward this state to your own itnernal state. In your case it is the lselected variable.
Timo Drick
09/10/2020, 10:04 AM