FSelectGroup<T> constructor
FSelectGroup<T> ({
- required FSelectGroupController<
T> controller, - required List<
FSelectGroupItem< children,T> > - FSelectGroupStyle? style,
- Widget? label,
- Widget? description,
- ValueChanged<
Set< ? onChange,T> > - ValueChanged<
(T, bool)> ? onSelect, - Widget errorBuilder() = FFormFieldProperties.defaultErrorBuilder,
- FormFieldSetter<
Set< ? onSaved,T> > - FormFieldValidator<
Set< ? validator,T> > - String? forceErrorText,
- bool enabled = true,
- AutovalidateMode? autovalidateMode,
- Key? key,
Creates a FSelectGroup.
Implementation
FSelectGroup({
required this.controller,
required this.children,
this.style,
this.label,
this.description,
this.onChange,
this.onSelect,
Widget Function(BuildContext, String) errorBuilder = FFormFieldProperties.defaultErrorBuilder,
super.onSaved,
super.validator,
super.forceErrorText,
super.enabled = true,
super.autovalidateMode,
super.key,
}) : super(
initialValue: controller.value,
errorBuilder: errorBuilder,
builder: (field) {
final state = field as _State;
final groupStyle = style ?? state.context.theme.selectGroupStyle;
final formStates = {if (!enabled) WidgetState.disabled, if (state.errorText != null) WidgetState.error};
return FLabel(
axis: Axis.vertical,
states: formStates,
style: groupStyle,
label: label,
description: description,
error: state.errorText == null ? null : errorBuilder(state.context, state.errorText!),
child: Column(
children: [
for (final child in children)
Padding(
padding: groupStyle.itemPadding,
child: FSelectGroupItemData<T>(
controller: controller,
style: groupStyle,
selected: controller.contains(child.value),
child: child,
),
),
],
),
);
},
);