ReactiveCheckbox constructor

ReactiveCheckbox({
  1. Key? key,
  2. String? formControlName,
  3. FormControl<bool>? formControl,
  4. bool tristate = false,
  5. Color? activeColor,
  6. Color? checkColor,
  7. Color? focusColor,
  8. Color? hoverColor,
  9. MouseCursor? mouseCursor,
  10. MaterialTapTargetSize? materialTapTargetSize,
  11. VisualDensity? visualDensity,
  12. bool autofocus = false,
  13. WidgetStateProperty<Color?>? fillColor,
  14. WidgetStateProperty<Color?>? overlayColor,
  15. double? splashRadius,
  16. FocusNode? focusNode,
  17. OutlinedBorder? shape,
  18. BorderSide? side,
  19. String? semanticLabel,
  20. ReactiveFormFieldCallback<bool>? onChanged,
  21. ShowErrorsFunction<bool>? showErrors,
})

Create an instance of a ReactiveCheckbox.

Can optionally provide a formControl to bind this widget to a control.

Can optionally provide a formControlName to bind this ReactiveFormField to a FormControl.

Must provide one of the arguments formControl or a formControlName, but not both at the same time.

For documentation about the various parameters, see the Checkbox class and the Checkbox constructor.

Implementation

ReactiveCheckbox({
  super.key,
  super.formControlName,
  super.formControl,
  bool tristate = false,
  Color? activeColor,
  Color? checkColor,
  Color? focusColor,
  Color? hoverColor,
  MouseCursor? mouseCursor,
  MaterialTapTargetSize? materialTapTargetSize,
  VisualDensity? visualDensity,
  bool autofocus = false,
  WidgetStateProperty<Color?>? fillColor,
  WidgetStateProperty<Color?>? overlayColor,
  double? splashRadius,
  super.focusNode,
  OutlinedBorder? shape,
  BorderSide? side,
  String? semanticLabel,
  ReactiveFormFieldCallback<bool>? onChanged,
  ShowErrorsFunction<bool>? showErrors,
}) : super(
       showErrors:
           showErrors ??
           (control) => control.invalid && (control.dirty || control.touched),
       builder: (field) {
         return Checkbox(
           value: tristate ? field.value : field.value ?? false,
           tristate: tristate,
           mouseCursor: mouseCursor,
           activeColor: activeColor,
           checkColor: checkColor,
           focusColor: focusColor,
           hoverColor: hoverColor,
           materialTapTargetSize: materialTapTargetSize,
           visualDensity: visualDensity,
           autofocus: autofocus,
           fillColor: fillColor,
           overlayColor: overlayColor,
           splashRadius: splashRadius,
           focusNode: field.focusNode,
           shape: shape,
           side: side,
           isError: field.errorText != null,
           onChanged:
               field.control.enabled
                   ? (value) {
                     field.didChange(value);
                     onChanged?.call(field.control);
                   }
                   : null,
           semanticLabel: semanticLabel,
         );
       },
     );