FSelectTileGroup<T> constructor

FSelectTileGroup<T>({
  1. required FSelectGroupController<T> controller,
  2. required List<FSelectTile<T>> children,
  3. FTileGroupStyle? style,
  4. FTileDivider divider = FTileDivider.indented,
  5. Widget? label,
  6. Widget? description,
  7. Widget errorBuilder(
    1. BuildContext,
    2. String
    ) = _errorBuilder,
  8. String? semanticLabel,
  9. FormFieldSetter<Set<T>>? onSaved,
  10. FormFieldValidator<Set<T>>? validator,
  11. Set<T>? initialValue,
  12. String? forceErrorText,
  13. bool enabled = true,
  14. AutovalidateMode? autovalidateMode,
  15. String? restorationId,
  16. Key? key,
})

Creates a FSelectTileGroup.

Implementation

FSelectTileGroup({
  required this.controller,
  required this.children,
  this.style,
  this.divider = FTileDivider.indented,
  this.label,
  this.description,
  this.errorBuilder = _errorBuilder,
  this.semanticLabel,
  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.tileGroupStyle;
          final (labelState, error) = switch (state.errorText) {
            _ when !enabled => (FLabelState.disabled, null),
            final text? => (FLabelState.error, errorBuilder(state.context, text)),
            null => (FLabelState.enabled, null),
          };

          return FTileGroup(
            style: groupStyle,
            divider: divider,
            label: label,
            enabled: enabled,
            description: description,
            error: error,
            semanticLabel: semanticLabel,
            children: [
              for (final child in children)
                FSelectTileData<T>(
                  controller: controller,
                  selected: controller.contains(child.value),
                  child: child,
                ),
            ],
          );
        },
      );