Reputation: 27
I can't seem to find a suitable solution fixing checkboxlisttile in a flutter, I'm a complete beginner working with flutter I went through the flutter docs CheckboxListTile class and it's not working for me.
Please I needed help in understanding this checkboxlisttile thing.
Upvotes: 0
Views: 58
Reputation: 27
I wrapped my code in a StatelessWidget instead of StatefulWidget, by doing so, i now fixed the problem. CheckboxListTile is now working thank you all for helping. This is the screenshot of my code sample before and after. [![enter image description here][1]][1]
I also rename my class name to MySales
Upvotes: 0
Reputation: 91
I assume you want to toggle between true and false upon clicking the CheckBoxListTile
.
Edit the following code inside your onChanged:
onChanged: (bool? value){
isChecked = !isChecked;
}
Upvotes: 1
Reputation: 63649
onChanged
provides nullable bool
final ValueChanged<bool?>? onChanged;
onChanged: (bool? value){
isChecked = value ?? false;
}
Upvotes: 0