FSelectGroup<T> constructor
FSelectGroup<T> ({
- required FSelectGroupController<
T> controller, - required List<
FSelectGroupItem< items,T> > - FSelectGroupStyle? style,
- Widget? label,
- Widget? description,
- Widget errorBuilder() = _errorBuilder,
- 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 = _errorBuilder,
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, error) = switch (state.errorText) {
_ when !enabled => (FLabelState.disabled, null),
final text? => (FLabelState.error, errorBuilder(state.context, text)),
null => (FLabelState.enabled, null),
};
return FLabel(
axis: Axis.vertical,
state: labelState,
style: groupStyle.labelStyle,
label: label,
description: description,
error: error,
child: Column(
children: [
for (final child in items)
FSelectGroupItemData<T>(
controller: controller,
style: groupStyle,
selected: controller.contains(child.value),
child: child,
),
],
),
);
},
);