ChipCheckGroupB<T> function

Wrap ChipCheckGroupB<T>(
  1. Binder<Set<T>> binder, {
  2. required Iterable<T> items,
  3. required OnWidget<T> onLabel,
  4. bool allowEmpty = true,
  5. Axis direction = Axis.horizontal,
  6. WrapAlignment alignment = WrapAlignment.start,
  7. double spacing = 8,
  8. WrapAlignment runAlignment = WrapAlignment.start,
  9. double runSpacing = 8,
  10. WrapCrossAlignment crossAxisAlignment = WrapCrossAlignment.start,
  11. TextDirection? textDirection,
  12. VerticalDirection verticalDirection = VerticalDirection.down,
  13. Clip clipBehavior = Clip.none,
  14. Widget? avatar,
  15. TextStyle? labelStyle,
  16. EdgeInsetsGeometry? labelPadding,
  17. double? pressElevation,
  18. Color? selectedColor = Colors.blueAccent,
  19. Color? disabledColor,
  20. String? tooltip,
  21. BorderSide? side,
  22. OutlinedBorder? shape,
  23. FocusNode? focusNode,
  24. bool autofocus = false,
  25. WidgetStateProperty<Color?>? color,
  26. Color? backgroundColor,
  27. EdgeInsetsGeometry? padding,
  28. VisualDensity? visualDensity,
})

Implementation

Wrap ChipCheckGroupB<T>(Binder<Set<T>> binder,
    {required Iterable<T> items,
    required OnWidget<T> onLabel,
    bool allowEmpty = true,
    Axis direction = Axis.horizontal,
    WrapAlignment alignment = WrapAlignment.start,
    double spacing = 8,
    WrapAlignment runAlignment = WrapAlignment.start,
    double runSpacing = 8,
    WrapCrossAlignment crossAxisAlignment = WrapCrossAlignment.start,
    TextDirection? textDirection,
    VerticalDirection verticalDirection = VerticalDirection.down,
    Clip clipBehavior = Clip.none,
    Widget? avatar,
    TextStyle? labelStyle,
    EdgeInsetsGeometry? labelPadding,
    double? pressElevation,
    Color? selectedColor = Colors.blueAccent,
    Color? disabledColor,
    String? tooltip,
    BorderSide? side,
    OutlinedBorder? shape,
    FocusNode? focusNode,
    bool autofocus = false,
    WidgetStateProperty<Color?>? color,
    Color? backgroundColor,
    EdgeInsetsGeometry? padding,
    VisualDensity? visualDensity}) {
  if (!allowEmpty && binder.value.isEmpty) {
    if (items.isNotEmpty) {
      binder.value.add(items.first);
    }
  }
  List<ChoiceChip> chips = items.mapList((T e) => ChoiceChip(
      label: onLabel(e),
      selected: binder.value.contains(e),
      elevation: 3,
      onSelected: (b) {
        Set<T> ls = binder.value;
        if (b) {
          if (!ls.contains(e)) {
            ls.add(e);
            binder.value = ls;
            binder.fireUpdateUI();
            binder.fireChanged();
          }
        } else {
          if (allowEmpty || binder.value.length > 1) {
            if (ls.contains(e)) {
              ls.remove(e);
              binder.value = ls;
              binder.fireUpdateUI();
              binder.fireChanged();
            }
          }
        }
      },
      avatar: avatar,
      labelStyle: labelStyle,
      labelPadding: labelPadding,
      pressElevation: pressElevation,
      selectedColor: selectedColor,
      disabledColor: disabledColor,
      tooltip: tooltip,
      side: side,
      shape: shape,
      focusNode: focusNode,
      autofocus: autofocus,
      color: color,
      backgroundColor: backgroundColor,
      padding: padding,
      visualDensity: visualDensity,
      clipBehavior: clipBehavior));
  return Wrap(
      children: chips,
      direction: direction,
      alignment: alignment,
      spacing: spacing,
      runAlignment: runAlignment,
      runSpacing: runSpacing,
      crossAxisAlignment: crossAxisAlignment,
      textDirection: textDirection,
      verticalDirection: verticalDirection,
      clipBehavior: clipBehavior);
}