mardi 28 août 2018

Checkbox List Not Updating

I created a widget list of checkboxes as shown and I am using it in the Build method as

Column(
children: mList;
)

The problem is that the checkbox does not change value on click. It's value and state remain the same. Although the click is registered(checked it). What am I doing wrong?

List<int> selectedList = [];
List<Widget> = mList;
createMenuWidget(Course courses) {
  for (int b = 0; b < courses.length; b++) {
    Map cmap = courses[b];
    mList.add(CheckboxListTile(
      onChanged: (bool value){
        setState(() {
          if(value){
            selectedList.add(cmap[course_id]);
          }else{
            selectedList.remove(cmap[course_id]);
          }
        });
      },
      value: selectedList.contains(cmap[course_id]),
      title: new Text(cmap[course_name]),
    ));
  }
} 




Aucun commentaire:

Enregistrer un commentaire