FormBuilderChoiceChips<T> constructor

FormBuilderChoiceChips<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. FormFieldErrorBuilder? errorBuilder,
  16. WrapAlignment alignment = WrapAlignment.start,
  17. ShapeBorder avatarBorder = const CircleBorder(),
  18. Color? backgroundColor,
  19. WrapCrossAlignment crossAxisAlignment = WrapCrossAlignment.start,
  20. Axis direction = Axis.horizontal,
  21. Color? disabledColor,
  22. double? elevation,
  23. EdgeInsets? labelPadding,
  24. TextStyle? labelStyle,
  25. MaterialTapTargetSize? materialTapTargetSize,
  26. EdgeInsets? padding,
  27. double? pressElevation,
  28. WrapAlignment runAlignment = WrapAlignment.start,
  29. double runSpacing = 0.0,
  30. Color? selectedColor,
  31. Color? selectedShadowColor,
  32. Color? shadowColor,
  33. BorderSide? side,
  34. OutlinedBorder? shape,
  35. double spacing = 0.0,
  36. TextDirection? textDirection,
  37. VerticalDirection verticalDirection = VerticalDirection.down,
  38. VisualDensity? visualDensity,
  39. bool showCheckmark = true,
  40. Color? surfaceTintColor,
  41. Clip clipBehavior = Clip.none,
  42. Color? checkmarkColor,
  43. bool autofocus = false,
  44. BoxConstraints? avatarBoxConstraints,
  45. ChipAnimationStyle? chipAnimationStyle,
  46. WidgetStateProperty<Color?>? color,
  47. IconThemeData? iconTheme,
  48. String? tooltip,
})

Creates a list of Chips that acts like radio buttons

Implementation

FormBuilderChoiceChips({
  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,
  super.errorBuilder,
  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.side,
  this.shape,
  this.spacing = 0.0,
  this.textDirection,
  this.verticalDirection = VerticalDirection.down,
  this.visualDensity,
  this.showCheckmark = true,
  this.surfaceTintColor,
  this.clipBehavior = Clip.none,
  this.checkmarkColor,
  this.autofocus = false,
  this.avatarBoxConstraints,
  this.chipAnimationStyle,
  this.color,
  this.iconTheme,
  this.tooltip,
}) : super(
       builder: (FormFieldState<T?> field) {
         final state = field as _FormBuilderChoiceChipState<T>;

         return Focus(
           focusNode: state.effectiveFocusNode,
           skipTraversal: true,
           canRequestFocus: state.enabled,
           debugLabel: 'FormBuilderChoiceChip-$name',
           child: InputDecorator(
             decoration: state.decoration,
             isFocused: state.effectiveFocusNode.hasFocus,
             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,
                     side: side,
                     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,
                     showCheckmark: showCheckmark,
                     surfaceTintColor: surfaceTintColor,
                     clipBehavior: clipBehavior,
                     checkmarkColor: checkmarkColor,
                     autofocus: autofocus,
                     avatarBoxConstraints: avatarBoxConstraints,
                     chipAnimationStyle: chipAnimationStyle,
                     color: color,
                     iconTheme: iconTheme,
                     tooltip: tooltip,
                   ),
               ],
             ),
           ),
         );
       },
     );