FormBuilderChoiceChip<T> constructor
FormBuilderChoiceChip<T> ({
- Key? key,
- required String name,
- FormFieldValidator<
T> ? validator, - T? initialValue,
- InputDecoration decoration = const InputDecoration(),
- ValueChanged<
T?> ? onChanged, - ValueTransformer<
T?> ? valueTransformer, - bool enabled = true,
- FormFieldSetter<
T> ? onSaved, - AutovalidateMode autovalidateMode = AutovalidateMode.disabled,
- VoidCallback? onReset,
- FocusNode? focusNode,
- required List<
FormBuilderFieldOption< options,T> > - Color? selectedColor,
- Color? disabledColor,
- Color? backgroundColor,
- Color? shadowColor,
- Color? selectedShadowColor,
- OutlinedBorder? shape,
- double? elevation,
- double? pressElevation,
- MaterialTapTargetSize? materialTapTargetSize,
- Axis direction = Axis.horizontal,
- WrapAlignment alignment = WrapAlignment.start,
- WrapCrossAlignment crossAxisAlignment = WrapCrossAlignment.start,
- WrapAlignment runAlignment = WrapAlignment.start,
- double runSpacing = 0.0,
- double spacing = 0.0,
- TextDirection? textDirection,
- VerticalDirection verticalDirection = VerticalDirection.down,
- EdgeInsets? labelPadding,
- TextStyle? labelStyle,
- EdgeInsets? padding,
- VisualDensity? visualDensity,
Creates a list of Chip
s that acts like radio buttons
Implementation
FormBuilderChoiceChip({
Key? key,
//From Super
required String name,
FormFieldValidator<T>? validator,
T? initialValue,
InputDecoration decoration = const InputDecoration(),
ValueChanged<T?>? onChanged,
ValueTransformer<T?>? valueTransformer,
bool enabled = true,
FormFieldSetter<T>? onSaved,
AutovalidateMode autovalidateMode = AutovalidateMode.disabled,
VoidCallback? onReset,
FocusNode? focusNode,
required this.options,
this.selectedColor,
this.disabledColor,
this.backgroundColor,
this.shadowColor,
this.selectedShadowColor,
this.shape,
this.elevation,
this.pressElevation,
this.materialTapTargetSize,
this.direction = Axis.horizontal,
this.alignment = WrapAlignment.start,
this.crossAxisAlignment = WrapCrossAlignment.start,
this.runAlignment = WrapAlignment.start,
this.runSpacing = 0.0,
this.spacing = 0.0,
this.textDirection,
this.verticalDirection = VerticalDirection.down,
this.labelPadding,
this.labelStyle,
this.padding,
this.visualDensity,
}) : super(
key: key,
initialValue: initialValue,
name: name,
validator: validator,
valueTransformer: valueTransformer,
onChanged: onChanged,
autovalidateMode: autovalidateMode,
onSaved: onSaved,
enabled: enabled,
onReset: onReset,
decoration: decoration,
focusNode: focusNode,
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 (FormBuilderFieldOption<T> option in options)
ChoiceChip(
label: option,
selected: field.value == option.value,
onSelected: state.enabled
? (selected) {
final choice = selected ? option.value : null;
state.requestFocus();
state.didChange(choice);
}
: null,
selectedColor: selectedColor,
disabledColor: disabledColor,
backgroundColor: backgroundColor,
shadowColor: shadowColor,
selectedShadowColor: selectedShadowColor,
// shape: shape,
elevation: elevation,
pressElevation: pressElevation,
materialTapTargetSize: materialTapTargetSize,
labelStyle: labelStyle,
labelPadding: labelPadding,
padding: padding,
visualDensity: visualDensity,
),
],
),
);
});