Flutter Checkbox Checkbox

There are two types of Flutter checkboxes: one is the Lite Checkbox checkbox, and the other is the CheckboxListTile checkbox with its own title and subtitle

Detailed parameter explanation

Attributesillustrate

Checkbox checkbox

valueWhether to check this box
onChangedListener called when the value of the checkbox should change
sadnessThe default is false, if true, the value of the checkbox can be true, false or null.
activeColorThe color to use when this checkbox is checked
checkColorThe color used for the check icon when this checkbox is selected
materialTapTargetSizeConfigure the minimum size of the tap target

CheckboxListTile Checkbox

valueWhether to check this box
onChangedListener called when the value of the checkbox should change
activeColorThe color to use when this checkbox is checked
titleList main title
subtitlelist subtitle
isThreeLineDefault false
denseWhether this list tile is part of a vertically dense list.
secondaryWidget to display in front of checkboxes
selectedWhen selected, the text is highlighted, the default is false
controlAffinity

the position of the control relative to the text,

Default ListTileControlAffinity.platform

code example

Checkbox checkbox

  1. Checkbox(
  2. value: this.valueb,
  3. onChanged: (bool value) {
  4. setState (() {
  5. this.valueb = value;
  6. });
  7. },
  8. ),

CheckboxListTile Checkbox

  1. CheckboxListTile(
  2. secondary: const Icon(Icons.alarm_on),
  3. title: const Text ( 'Bell every day at 6:10' ),
  4. subtitle: Text ( 'Bell in 12 hours and 58 minutes' ),
  5. value: this.valued,
  6. onChanged: (bool value) {
  7. setState (() {
  8. this.valued = value;
  9. });
  10. },
  11. ),

renderings

full code

View full code

Related: Flutter Checkbox Checkbox