group static method

Widget group({
  1. required List<String> options,
  2. required List<String> selectedValues,
  3. required ValueChanged<List<String>> onChanged,
  4. bool isDisabled = false,
  5. String? errorText,
})

Implementation

static Widget group({
  required List<String> options,
  required List<String> selectedValues,
  required ValueChanged<List<String>> onChanged,
  bool isDisabled = false,
  String? errorText,
}) {
  return Column(
    crossAxisAlignment: CrossAxisAlignment.start,
    children: [
      Wrap(
        spacing: 12,
        runSpacing: 8,
        children: options.map((option) {
          final isSelected = selectedValues.contains(option);
          return UiCheckbox(
            label: option,
            value: isSelected,
            isDisabled: isDisabled,
            onChanged: (checked) {
              final updated = List<String>.from(selectedValues);
              checked ? updated.add(option) : updated.remove(option);
              onChanged(updated);
            },
          );
        }).toList(),
      ),
      if (errorText != null)
        Padding(
          padding: const EdgeInsets.only(top: 4),
          child: Text(errorText, style: const TextStyle(color: Colors.red)),
        ),
    ],
  );
}