FormCheckbox constructor

FormCheckbox({
  1. Key? key,
  2. bool? initialValue,
  3. ValueChanged<bool?>? onChanged,
  4. List<String>? labels,
})

Implementation

FormCheckbox({
  Key? key,
  bool? initialValue,
  ValueChanged<bool?>? onChanged,
  List<String>? labels,
}) : super(
          key: key,
          initialValue: initialValue ?? false,
          builder: (FormFieldState<bool> field) {
            final _FormCheckboxState state = field as _FormCheckboxState;
            void onChangedHandler(bool? value) {
              state.didChange(value);
              if (onChanged != null) {
                onChanged(value);
              }
            }

            return Checkbox(
                value: state.value,
                onChanged: (v) {
                  onChangedHandler(v);
                });
          });