Here's the code:
Checkbox(
value: value,
onChanged: (newValue) {
setState(() => value = newValue);
// Restructure data based on new value
_restructureData(newValue);
}
activeColor: Colors.orange,
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
tristate: true,
);
However, since tristate = true
, so if you are in null
position going to true
you need to press twice (null
=> false
=> true
). But this also means that _restructureData(newValue)
is called twice.
So how do I call _restructureData(newValue)
only once the user finish tapping the check box whether it is once, twice or how many times he/she wants to press it before he stops?
Aucun commentaire:
Enregistrer un commentaire