lundi 26 octobre 2020

Display checkbox in listView flutter

Please help ! I have two checkbox in table row. First checkBox is clickable but the second are not clickable.

 ListView.builder(
                    shrinkWrap: true,
                    physics: const NeverScrollableScrollPhysics(),
                    itemCount: widget.checklist['sections'].length,
                    itemBuilder: (context, index) {
                      final item = widget.checklist['sections'][index];

                      String s = item['applicable'];
                      var a = s.split(",");

                      return Column(
                          crossAxisAlignment: CrossAxisAlignment.start,
                          children: [
                            Table(
                                columnWidths: {
                                  0: FixedColumnWidth(
                                      250.0), // fixed to 100 width
                                  1: FlexColumnWidth(),
                                  2: FlexColumnWidth(), //fixed to 100 width
                                },
                                defaultColumnWidth: FixedColumnWidth(120),
                                border: TableBorder.all(),
                                children: [
                                  TableRow(children: [
                                    TableCell(
                                        child: Container(
                                            color: Colors.grey.shade300,
                                            child: Padding(
                                                padding: EdgeInsets.all(10),
                                                child: Text(item['name'])))),
                                    for (var i in a)
                                      TableCell(
                                          child: Container(
                                              color: Colors.grey.shade300,
                                              child: Padding(
                                                  padding: EdgeInsets.all(10),
                                                  child: Text(i))))
                                  ]),
                                  ...item['questions']
                                      .asMap()
                                      .entries
                                      .map((items) {
                                    print(items.key);
                                    return TableRow(children: [
                                      Padding(
                                          padding: EdgeInsets.all(10),
                                          child: Text(items.value['name'])),
                                      Checkbox(
                                       tristate: true,
                                       value: true,
                                        onChanged: (bool value) {
                                          setState(() {
                                            widget.checklist['sections']
                                                [items.keys] = value;
                                          });
                                        },
                                      ),
                                      Checkbox(onChanged: null, value: false)
                                    ]);
                                  }).toList()
                                ])
                          ]);
                      // );
                    })

But I get this error

'package:flutter/src/material/checkbox.dart': Failed assertion: line 76 pos 15: 'tristate || value != null': is not true.



Aucun commentaire:

Enregistrer un commentaire