ToggleButtons constructor Null safety

const ToggleButtons(
  1. {Key? key,
  2. required List<Widget> children,
  3. required List<bool> isSelected,
  4. void onPressed(
    1. int index
    )?,
  5. MouseCursor? mouseCursor,
  6. MaterialTapTargetSize? tapTargetSize,
  7. TextStyle? textStyle,
  8. BoxConstraints? constraints,
  9. Color? color,
  10. Color? selectedColor,
  11. Color? disabledColor,
  12. Color? fillColor,
  13. Color? focusColor,
  14. Color? highlightColor,
  15. Color? hoverColor,
  16. Color? splashColor,
  17. List<FocusNode>? focusNodes,
  18. bool renderBorder = true,
  19. Color? borderColor,
  20. Color? selectedBorderColor,
  21. Color? disabledBorderColor,
  22. BorderRadius? borderRadius,
  23. double? borderWidth,
  24. Axis direction = Axis.horizontal,
  25. 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);