FormBuilderChoiceChip<T> constructor

FormBuilderChoiceChip<T>({
  1. AutovalidateMode? autovalidateMode = AutovalidateMode.disabled,
  2. bool enabled = true,
  3. FocusNode? focusNode,
  4. FormFieldSetter<T>? onSaved,
  5. FormFieldValidator<T>? validator,
  6. InputDecoration decoration = const InputDecoration(),
  7. Key? key,
  8. required String name,
  9. required List<FormBuilderChipOption<T>> options,
  10. T? initialValue,
  11. String? restorationId,
  12. ValueChanged<T?>? onChanged,
  13. ValueTransformer<T?>? valueTransformer,
  14. VoidCallback? onReset,
  15. WrapAlignment alignment = WrapAlignment.start,
  16. ShapeBorder avatarBorder = const CircleBorder(),
  17. Color? backgroundColor,
  18. WrapCrossAlignment crossAxisAlignment = WrapCrossAlignment.start,
  19. Axis direction = Axis.horizontal,
  20. Color? disabledColor,
  21. double? elevation,
  22. EdgeInsets? labelPadding,
  23. TextStyle? labelStyle,
  24. MaterialTapTargetSize? materialTapTargetSize,
  25. EdgeInsets? padding,
  26. double? pressElevation,
  27. WrapAlignment runAlignment = WrapAlignment.start,
  28. double runSpacing = 0.0,
  29. Color? selectedColor,
  30. Color? selectedShadowColor,
  31. Color? shadowColor,
  32. OutlinedBorder? shape,
  33. double spacing = 0.0,
  34. TextDirection? textDirection,
  35. VerticalDirection verticalDirection = VerticalDirection.down,
  36. VisualDensity? visualDensity,
})

Creates a list of Chips that acts like radio buttons

Implementation

FormBuilderChoiceChip({
  super.autovalidateMode = AutovalidateMode.disabled,
  super.enabled,
  super.focusNode,
  super.onSaved,
  super.validator,
  super.decoration,
  super.key,
  required super.name,
  required this.options,
  super.initialValue,
  super.restorationId,
  super.onChanged,
  super.valueTransformer,
  super.onReset,
  this.alignment = WrapAlignment.start,
  this.avatarBorder = const CircleBorder(),
  this.backgroundColor,
  this.crossAxisAlignment = WrapCrossAlignment.start,
  this.direction = Axis.horizontal,
  this.disabledColor,
  this.elevation,
  this.labelPadding,
  this.labelStyle,
  this.materialTapTargetSize,
  this.padding,
  this.pressElevation,
  this.runAlignment = WrapAlignment.start,
  this.runSpacing = 0.0,
  this.selectedColor,
  this.selectedShadowColor,
  this.shadowColor,
  this.shape,
  this.spacing = 0.0,
  this.textDirection,
  this.verticalDirection = VerticalDirection.down,
  this.visualDensity,
}) : super(builder: (FormFieldState<T?> field) {
        final state = field as _FormBuilderChoiceChipState<T>;

        return InputDecorator(
          decoration: state.decoration,
          child: Wrap(
            direction: direction,
            alignment: alignment,
            crossAxisAlignment: crossAxisAlignment,
            runAlignment: runAlignment,
            runSpacing: runSpacing,
            spacing: spacing,
            textDirection: textDirection,
            verticalDirection: verticalDirection,
            children: <Widget>[
              for (FormBuilderChipOption<T> option in options)
                ChoiceChip(
                  label: option,
                  shape: shape,
                  selected: field.value == option.value,
                  onSelected: state.enabled
                      ? (selected) {
                          final choice = selected ? option.value : null;
                          state.didChange(choice);
                        }
                      : null,
                  avatar: option.avatar,
                  selectedColor: selectedColor,
                  disabledColor: disabledColor,
                  backgroundColor: backgroundColor,
                  shadowColor: shadowColor,
                  selectedShadowColor: selectedShadowColor,
                  elevation: elevation,
                  pressElevation: pressElevation,
                  materialTapTargetSize: materialTapTargetSize,
                  labelStyle: labelStyle,
                  labelPadding: labelPadding,
                  padding: padding,
                  visualDensity: visualDensity,
                  avatarBorder: avatarBorder,
                ),
            ],
          ),
        );
      });