Checkbox constructor

const Checkbox(
  1. {Key key,
  2. @required bool value,
  3. bool tristate: false,
  4. @required ValueChanged<bool> onChanged,
  5. Color activeColor,
  6. Color checkColor,
  7. Color focusColor,
  8. Color hoverColor,
  9. MaterialTapTargetSize materialTapTargetSize,
  10. VisualDensity visualDensity,
  11. FocusNode focusNode,
  12. bool autofocus: false}

Creates a material design checkbox.

The checkbox 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 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.

The values of tristate and autofocus must not be null.


const Checkbox({
  Key key,
  @required this.value,
  this.tristate = false,
  @required this.onChanged,
  this.autofocus = false,
}) : assert(tristate != null),
     assert(tristate || value != null),
     assert(autofocus != null),
     super(key: key);