CupertinoSlidingSegmentedControl<T extends Object> constructor

CupertinoSlidingSegmentedControl<T extends Object>({
  1. Key? key,
  2. required Map<T, Widget> children,
  3. required ValueChanged<T?> onValueChanged,
  4. Set<T> disabledChildren = const <Never>{},
  5. T? groupValue,
  6. Color thumbColor = _kThumbColor,
  7. EdgeInsetsGeometry padding = _kHorizontalItemPadding,
  8. Color backgroundColor = CupertinoColors.tertiarySystemFill,
  9. bool proportionalWidth = false,
})

Creates an iOS-style segmented control bar.

The children argument must be an ordered Map such as a LinkedHashMap. Further, the length of the children list must be greater than one.

Each widget value in the map of children must have an associated key that uniquely identifies this widget. This key is what will be returned in the onValueChanged callback when a new value from the children map is selected.

The groupValue is the currently selected value for the segmented control. If no groupValue is provided, or the groupValue is null, no widget will appear as selected. The groupValue must be either null or one of the keys in the children map.

Implementation

CupertinoSlidingSegmentedControl({
  super.key,
  required this.children,
  required this.onValueChanged,
  this.disabledChildren = const <Never>{},
  this.groupValue,
  this.thumbColor = _kThumbColor,
  this.padding = _kHorizontalItemPadding,
  this.backgroundColor = CupertinoColors.tertiarySystemFill,
  this.proportionalWidth = false,
}) : assert(children.length >= 2),
     assert(
       groupValue == null || children.keys.contains(groupValue),
       'The groupValue must be either null or one of the keys in the children map.',
     );