FormBuilderChoiceChip<T> constructor
FormBuilderChoiceChip<T> ({
- AutovalidateMode? autovalidateMode = AutovalidateMode.disabled,
- bool enabled = true,
- FocusNode? focusNode,
- FormFieldSetter<
T> ? onSaved, - FormFieldValidator<
T> ? validator, - InputDecoration decoration = const InputDecoration(),
- Key? key,
- required String name,
- required List<
FormBuilderChipOption< options,T> > - T? initialValue,
- WrapAlignment alignment = WrapAlignment.start,
- ShapeBorder avatarBorder = const CircleBorder(),
- Color? backgroundColor,
- WrapCrossAlignment crossAxisAlignment = WrapCrossAlignment.start,
- Axis direction = Axis.horizontal,
- Color? disabledColor,
- double? elevation,
- EdgeInsets? labelPadding,
- TextStyle? labelStyle,
- MaterialTapTargetSize? materialTapTargetSize,
- EdgeInsets? padding,
- double? pressElevation,
- WrapAlignment runAlignment = WrapAlignment.start,
- double runSpacing = 0.0,
- Color? selectedColor,
- Color? selectedShadowColor,
- Color? shadowColor,
- OutlinedBorder? shape,
- bool shouldRequestFocus = false,
- double spacing = 0.0,
- TextDirection? textDirection,
- VerticalDirection verticalDirection = VerticalDirection.down,
- VisualDensity? visualDensity,
- ValueChanged<
T?> ? onChanged, - ValueTransformer<
T?> ? valueTransformer, - VoidCallback? onReset,
Creates a list of Chip
s 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,
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.shouldRequestFocus = false,
this.spacing = 0.0,
this.textDirection,
this.verticalDirection = VerticalDirection.down,
this.visualDensity,
super.onChanged,
super.valueTransformer,
super.onReset,
}) : 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;
if (shouldRequestFocus) {
state.requestFocus();
}
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,
),
],
),
);
});