CupertinoMultipleSegmentedControl class
An iOS-style segmented control that allows multiple children selected or none.
Displays the widgets provided in the Map of children in a horizontal list. Used to select between a number of options. When one option in the segmented control is selected, the other options in the segmented control keep their selected state.
A segmented control can feature any Widget as one of the values in its Map of children. The type T is the type of the keys used to identify each widget and determine which widget is selected. As required by the Map class, keys must be of consistent types and must be comparable. The ordering of the keys will determine the order of the widgets in the segmented control.
When the state of the segmented control changes, the widget calls the
onValueChanged
callback. The map key associated with the newly selected
widget is returned in the onValueChanged
callback. Typically, widgets
that use a segmented control will listen for the onValueChanged
callback
and rebuild the segmented control with a new groupValue
to update which
option is currently selected.
The children will be displayed in the order of the keys in the Map. The height of the segmented control is determined by the height of the tallest widget provided as a value in the Map of children. The width of each child in the segmented control will be equal to the width of widest child, unless the combined width of the children is wider than the available horizontal space. In this case, the available horizontal space is divided by the number of provided children to determine the width of each widget. The selection area for each of the widgets in the Map of children will then be expanded to fill the calculated space, so each widget will appear to have the same dimensions.
A segmented control may optionally be created with custom colors. The unselectedColor, selectedColor, borderColor, and pressedColor arguments can be used to override the segmented control's colors from CupertinoTheme defaults.
See also:
- CupertinoSegmentedControl, a segmented control widget in the style used up until iOS 13.
- developer.apple.com/design/human-interface-guidelines/ios/controls/segmented-controls/
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- CupertinoMultipleSegmentedControl
Constructors
-
CupertinoMultipleSegmentedControl.new({Key? key, required List<
Widget> children, required List<bool> isSelected, required dynamic onPressed(int index)?, Color? unselectedColor, Color? selectedColor, Color? borderColor, Color? pressedColor, EdgeInsetsGeometry? padding}) - Creates an iOS-style segmented control bar.
Properties
- borderColor → Color?
-
The color used as the border around each widget.
final
-
children
→ List<
Widget> -
The identifying keys and corresponding widget values in the
segmented control.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
-
isSelected
→ List<
bool> -
Each children element is either selected or not selected, in which case this elements isSelected value is true or false respectively.
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- onPressed → dynamic Function(int index)?
-
Callback when an element has been pressed
final
- padding → EdgeInsetsGeometry?
-
The CupertinoMultipleSegmentedControl will be placed inside this padding.
final
- pressedColor → Color?
-
The color used to fill the background of the widget the user is
temporarily interacting with through a long press or drag.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- selectedColor → Color?
-
The color used to fill the background of the selected widget and as the text
color of unselected widgets.
final
- unselectedColor → Color?
-
The callback that is called when a new option is tapped.
final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< CupertinoMultipleSegmentedControl> -
Creates the mutable state for this widget at a given location in the tree.
override
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of DiagnosticsNode objects describing this node's
children.
inherited
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String -
Returns a string representation of this node and its descendants.
inherited
-
toStringShallow(
{String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a one-line detailed description of the object.
inherited
-
toStringShort(
) → String -
A short, textual description of this widget.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited