CupertinoSegmentedControl<T> constructor

CupertinoSegmentedControl<T>({Key key, @required Map<T, Widget> children, @required ValueChanged<T> onValueChanged, T groupValue, Color unselectedColor: CupertinoColors.white, Color selectedColor: CupertinoColors.activeBlue, Color borderColor: CupertinoColors.activeBlue, Color pressedColor: const Color(0x33007AFF) })

Creates an iOS-style segmented control bar.

The children, onValueChanged, unselectedColor, selectedColor, borderColor, and pressedColor arguments must not be null. 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

CupertinoSegmentedControl({
  Key key,
  @required this.children,
  @required this.onValueChanged,
  this.groupValue,
  this.unselectedColor = CupertinoColors.white,
  this.selectedColor = CupertinoColors.activeBlue,
  this.borderColor = CupertinoColors.activeBlue,
  this.pressedColor = const Color(0x33007AFF),
})  : assert(children != null),
      assert(children.length >= 2),
      assert(onValueChanged != null),
      assert(groupValue == null || children.keys.any((T child) => child == groupValue),
      'The groupValue must be either null or one of the keys in the children map.'),
      assert(unselectedColor != null),
      assert(selectedColor != null),
      assert(borderColor != null),
      assert(pressedColor != null),
      super(key: key);