i have code that helps me dynamically create checkbox buttons from data in my api , now I need a way to help change the state of the check box values when i tap or untap them ,how can go about doing this –
for (int i = 0; i < data.names.length;i++)
CheckboxListTile(
title: Text(data.names[i]),
value: false,
onChanged: (value) {
})
2
Answers
Just use a variable and update it every time to change the checkbox.
In your onChange you set it to the current value and update your ui.
And set the current value of your checkbox to the variable (so it isn’t false every time):
i have create demo code as per your requirement ant try this demo: