FSelectGroup<T> constructor

FSelectGroup<T>({
  1. required FSelectGroupController<T> controller,
  2. required List<FSelectGroupItem<T>> items,
  3. FSelectGroupStyle? style,
  4. Widget? label,
  5. Widget? description,
  6. Widget errorBuilder(
    1. BuildContext,
    2. String
    ) = _defaultErrorBuilder,
  7. FormFieldSetter<Set<T>>? onSaved,
  8. FormFieldValidator<Set<T>>? validator,
  9. Set<T>? initialValue,
  10. String? forceErrorText,
  11. bool enabled = true,
  12. AutovalidateMode? autovalidateMode,
  13. String? restorationId,
  14. 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),
                  ),
              ],
            ),
          );
        },
      );