I'm making a cinema app. I made the seat selection using checkbox. I would like to deactivate the checkbox of the reserved seat among 200 seats (column: 10 row: 20).
I know that if I input onChanged of the checkbox as null, it will be disabled. The problem is that I created 200 CheckBoxes in one CheckBox class. Is there a part to disable only a part of it?
Positioned(
top: 45,
left: 16,
right: 16,
child: GridView.count(
shrinkWrap: true,
crossAxisCount: 20,
mainAxisSpacing: 2,
crossAxisSpacing: 2,
children: List.generate(200, (index) {
int column = (index % 200).toInt();
return Theme(
data: ThemeData(
primarySwatch: Colors.red,
unselectedWidgetColor: Colors.blueGrey,
),
child: Checkbox(
checkColor: Colors.white,
value: widget.seat![widget.index!][column],
onChanged: (selected) {
setState(() {
// widget.selected[row][column] = selected!;
if (widget.seat![widget.index!][column] == false) {
widget.seat![widget.index!][column] = true;
seat_select++;
} else if (widget.seat![widget.index!][column] == true) {
widget.seat![widget.index!][column] = false;
seat_select--;
}
});
}),
);
}),
),
),
Aucun commentaire:
Enregistrer un commentaire