CheckboxFormField constructor

CheckboxFormField({
  1. dynamic title,
  2. dynamic onSaved,
  3. dynamic validator,
  4. dynamic onChanged,
  5. dynamic initialValue = false,
  6. dynamic key,
})

Implementation

CheckboxFormField({
  Widget? title,
  super.onSaved,
  super.validator,
  FormFieldSetter<bool>? onChanged,
  super.initialValue = false,
  super.key,
}) : super(
        builder: (FormFieldState<bool> state) {
          return CheckboxListTile(
            dense: state.hasError,
            title: title,
            value: state.value,
            onChanged: (value) {
              state.didChange(value);
              if (onChanged != null) {
                onChanged(value);
              }
            },
            subtitle: state.hasError
                ? Builder(
                    builder: (BuildContext context) => Text(
                      state.errorText ?? '',
                      style: TextStyle(
                        color: Theme.of(context).colorScheme.error,
                      ),
                    ),
                  )
                : null,
            controlAffinity: ListTileControlAffinity.leading,
          );
        },
      );