ToggleButtons constructor Null safety
- {Key? key,
- required List<
Widget> children, - required List<
bool> isSelected, - void onPressed(
- int index
- MouseCursor? mouseCursor,
- MaterialTapTargetSize? tapTargetSize,
- TextStyle? textStyle,
- BoxConstraints? constraints,
- Color? color,
- Color? selectedColor,
- Color? disabledColor,
- Color? fillColor,
- Color? focusColor,
- Color? highlightColor,
- Color? hoverColor,
- Color? splashColor,
- List<
FocusNode> ? focusNodes, - bool renderBorder = true,
- Color? borderColor,
- Color? selectedBorderColor,
- Color? disabledBorderColor,
- BorderRadius? borderRadius,
- double? borderWidth,
- Axis direction = Axis.horizontal,
- VerticalDirection verticalDirection = VerticalDirection.down}
Creates a set of toggle buttons.
It displays its widgets provided in a List of children along direction. The state of each button is controlled by isSelected, which is a list of bools that determine if a button is in an active, disabled, or selected state. They are both correlated by their index in the list. The length of isSelected has to match the length of the children list.
Both children and isSelected properties arguments are required.
isSelected values must be non-null. focusNodes must be null or a list of non-null nodes. renderBorder and direction must not be null. If direction is Axis.vertical, verticalDirection must not be null.
Implementation
const ToggleButtons({
super.key,
required this.children,
required this.isSelected,
this.onPressed,
this.mouseCursor,
this.tapTargetSize,
this.textStyle,
this.constraints,
this.color,
this.selectedColor,
this.disabledColor,
this.fillColor,
this.focusColor,
this.highlightColor,
this.hoverColor,
this.splashColor,
this.focusNodes,
this.renderBorder = true,
this.borderColor,
this.selectedBorderColor,
this.disabledBorderColor,
this.borderRadius,
this.borderWidth,
this.direction = Axis.horizontal,
this.verticalDirection = VerticalDirection.down,
}) :
assert(children != null),
assert(isSelected != null),
assert(children.length == isSelected.length),
assert(direction != null),
assert(direction == Axis.horizontal || verticalDirection != null);