SegmentedButton<T> constructor
- Key? key,
- required List<
ButtonSegment< segments,T> > - required Set<
T> selected, - void onSelectionChanged(
- Set<
T>
- Set<
- bool multiSelectionEnabled = false,
- bool emptySelectionAllowed = false,
- EdgeInsets? expandedInsets,
- ButtonStyle? style,
- bool showSelectedIcon = true,
- Widget? selectedIcon,
Creates a const SegmentedButton.
segments must contain at least one segment, but it is recommended to have two to five segments. If you need only single segment, consider using a Checkbox or Radio widget instead. If you need more than five options, consider using FilterChip or ChoiceChip widgets.
If onSelectionChanged is null, then the entire segmented button will be disabled.
By default selected must only contain one entry. However, if multiSelectionEnabled is true, then selected can contain multiple entries. If emptySelectionAllowed is true, then selected can be empty.
Implementation
const SegmentedButton({
super.key,
required this.segments,
required this.selected,
this.onSelectionChanged,
this.multiSelectionEnabled = false,
this.emptySelectionAllowed = false,
this.expandedInsets,
this.style,
this.showSelectedIcon = true,
this.selectedIcon,
}) : assert(segments.length > 0),
assert(selected.length > 0 || emptySelectionAllowed),
assert(selected.length < 2 || multiSelectionEnabled);