FSelectGroup<T> constructor
FSelectGroup<T> ({
- required FSelectGroupController<
T> controller, - required List<
FSelectGroupItem< items,T> > - FSelectGroupStyle? style,
- Widget? label,
- Widget? description,
- Widget errorBuilder() = _defaultErrorBuilder,
- FormFieldSetter<
Set< ? onSaved,T> > - FormFieldValidator<
Set< ? validator,T> > - Set<
T> ? initialValue, - String? forceErrorText,
- bool enabled = true,
- AutovalidateMode? autovalidateMode,
- String? restorationId,
- Key? key,
Creates a FSelectGroup.
Implementation
FSelectGroup({
required this.controller,
required this.items,
this.style,
this.label,
this.description,
this.errorBuilder = _defaultErrorBuilder,
super.onSaved,
super.validator,
super.initialValue,
super.forceErrorText,
super.enabled = true,
super.autovalidateMode,
super.restorationId,
super.key,
}) : super(
builder: (field) {
final state = field as _State;
final groupStyle = style ?? state.context.theme.selectGroupStyle;
final labelState = switch (state) {
_ when !enabled => FLabelState.disabled,
_ when state.errorText != null => FLabelState.error,
_ => FLabelState.enabled,
};
return FLabel(
axis: Axis.vertical,
state: labelState,
style: groupStyle.labelStyle,
label: label,
description: description,
error: labelState == FLabelState.error ? errorBuilder(state.context, state.errorText!) : null,
child: Column(
children: [
for (final item in items)
item.builder(
state.context,
controller.select,
controller.contains(item.value),
),
],
),
);
},
);