selectAt method

void selectAt(
  1. int index
)

Sets the value of the selected item in this controller's radio group to the value of the element at index in the radio group's value list.

Note: By setting index to -1, the radio group will deselect all options.

@throws IndexOutOfBoundsException If the index provided is not within the range of the radio group's value list.

@throws ControllerDecoupledException If the controller cannot access the value of its radio group.

Implementation

void selectAt(int index) {
  if (_myRadioGroup != null) {
    if (index == -1) {
      value = null;
    } else if (index >= 0 && index < _myRadioGroup!.widget.values.length) {
      value = _myRadioGroup!.widget.values[index];
    } else {
      throw IndexOutOfBoundsException(
        index: index,
        iterable: _myRadioGroup!.widget.values,
      );
    }
  }
}