ShadToggleGroup<T> constructor

const ShadToggleGroup<T>({
  1. Key? key,
  2. required List<ShadToggleGroupItem<T>> children,
  3. Set<T>? values,
  4. ValueChanged<Set<T>>? onChanged,
  5. ShadToggleGroupController<T>? controller,
  6. bool allowDeselection = true,
  7. bool enabled = true,
  8. ShadToggleVariant toggleVariant = ShadToggleVariant.default_,
  9. double? gap,
  10. Axis axis = Axis.horizontal,
  11. MainAxisSize mainAxisSize = MainAxisSize.min,
})

A set of ShadToggles sharing a selection.

Mirrors shadcn/ui's ToggleGroup, in single or multiple mode.

ShadToggleGroup<String>(
  values: const {'bold'},
  onChanged: (values) => setState(() => selected = values),
  children: const [
    ShadToggleGroupItem(value: 'bold', child: Icon(LucideIcons.bold)),
    ShadToggleGroupItem(value: 'italic', child: Icon(LucideIcons.italic)),
  ],
)

Implementation

const ShadToggleGroup({
  super.key,
  required this.children,
  this.values,
  this.onChanged,
  this.controller,
  this.allowDeselection = true,
  this.enabled = true,
  this.toggleVariant = ShadToggleVariant.default_,
  this.gap,
  this.axis = Axis.horizontal,
  this.mainAxisSize = MainAxisSize.min,
}) : variant = ShadToggleGroupVariant.single;