Skip to content

Commit adf30ad

Browse files
committed
Allow null value on checkbox if tristate is enabled
1 parent c41e0b8 commit adf30ad

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/src/fields/form_builder_checkbox.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class _FormBuilderCheckboxState extends State<FormBuilderCheckbox> {
6464

6565
Widget _checkbox(FormFieldState<dynamic> field) {
6666
return Checkbox(
67-
value: field.value ?? false,
67+
value: (field.value == null && !widget.tristate) ? false : field.value,
6868
activeColor: widget.activeColor,
6969
checkColor: widget.checkColor,
7070
materialTapTargetSize: widget.materialTapTargetSize,
@@ -96,7 +96,7 @@ class _FormBuilderCheckboxState extends State<FormBuilderCheckbox> {
9696
return FormField(
9797
key: _fieldKey,
9898
enabled: !_readOnly,
99-
initialValue: _initialValue ?? false,
99+
initialValue: _initialValue,
100100
validator: (val) {
101101
for (int i = 0; i < widget.validators.length; i++) {
102102
if (widget.validators[i](val) != null)

0 commit comments

Comments
 (0)