CheckboxListTile constructor

const CheckboxListTile({
  1. Key? key,
  2. required bool? value,
  3. required ValueChanged<bool?>? onChanged,
  4. MouseCursor? mouseCursor,
  5. Color? activeColor,
  6. MaterialStateProperty<Color?>? fillColor,
  7. Color? checkColor,
  8. Color? hoverColor,
  9. MaterialStateProperty<Color?>? overlayColor,
  10. double? splashRadius,
  11. MaterialTapTargetSize? materialTapTargetSize,
  12. VisualDensity? visualDensity,
  13. FocusNode? focusNode,
  14. bool autofocus = false,
  15. ShapeBorder? shape,
  16. BorderSide? side,
  17. bool isError = false,
  18. bool? enabled,
  19. Color? tileColor,
  20. Widget? title,
  21. Widget? subtitle,
  22. bool isThreeLine = false,
  23. bool? dense,
  24. Widget? secondary,
  25. bool selected = false,
  26. ListTileControlAffinity? controlAffinity,
  27. EdgeInsetsGeometry? contentPadding,
  28. bool tristate = false,
  29. OutlinedBorder? checkboxShape,
  30. Color? selectedTileColor,
  31. ValueChanged<bool>? onFocusChange,
  32. bool? enableFeedback,
  33. String? checkboxSemanticLabel,
  34. double checkboxScaleFactor = 1.0,
  35. bool internalAddSemanticForOnTap = false,
})

Creates a combination of a list tile and a checkbox.

The checkbox tile itself does not maintain any state. Instead, when the state of the checkbox changes, the widget calls the onChanged callback. Most widgets that use a checkbox will listen for the onChanged callback and rebuild the checkbox tile with a new value to update the visual appearance of the checkbox.

The following arguments are required:

  • value, which determines whether the checkbox is checked. The value can only be null if tristate is true.
  • onChanged, which is called when the value of the checkbox should change. It can be set to null to disable the checkbox.

Implementation

const CheckboxListTile({
  super.key,
  required this.value,
  required this.onChanged,
  this.mouseCursor,
  this.activeColor,
  this.fillColor,
  this.checkColor,
  this.hoverColor,
  this.overlayColor,
  this.splashRadius,
  this.materialTapTargetSize,
  this.visualDensity,
  this.focusNode,
  this.autofocus = false,
  this.shape,
  this.side,
  this.isError = false,
  this.enabled,
  this.tileColor,
  this.title,
  this.subtitle,
  this.isThreeLine = false,
  this.dense,
  this.secondary,
  this.selected = false,
  this.controlAffinity,
  this.contentPadding,
  this.tristate = false,
  this.checkboxShape,
  this.selectedTileColor,
  this.onFocusChange,
  this.enableFeedback,
  this.checkboxSemanticLabel,
  this.checkboxScaleFactor = 1.0,
  this.internalAddSemanticForOnTap = false,
}) : _checkboxType = _CheckboxType.material,
     assert(tristate || value != null),
     assert(!isThreeLine || subtitle != null);