RadioGroup<T> constructor

RadioGroup<T>({
  1. GlobalKey<RadioGroupState<T>>? key,
  2. RadioGroupController<T>? controller,
  3. required List<T> values,
  4. Widget labelBuilder(
    1. T value
    )?,
  5. void onChanged(
    1. T? value
    )?,
  6. int indexOfDefault = -1,
  7. RadioGroupOrientation orientation = RadioGroupOrientation.vertical,
  8. RadioGroupDecoration? decoration,
})

Creates a widget which contains Radio buttons that a user can click to make selections within the app.

Note: Any value in values that is not a Widget will be displayed as a string in a Text widget for the button's label, unless labelBuilder is provided.

Implementation

RadioGroup({
  GlobalKey<RadioGroupState<T>>? key,
  this.controller,
  required this.values,
  this.labelBuilder,
  this.onChanged,
  this.indexOfDefault = -1,
  this.orientation = RadioGroupOrientation.vertical,
  this.decoration,
})  : assert(
          indexOfDefault < values.length,
          "ERROR: `indexOfDefault` is out of bounds for the range of "
          "`values`!"),
      _controller = controller ?? RadioGroupController<T>(),
      super(
          key: key ??
              controller?.myRadioGroupKey ??
              GlobalKey<RadioGroupState<T>>()) {
  if (controller == null && key == null) {
    if (kDebugMode) {
      log(
        'RadioGroup Warning: You have not included a `key` or a `controller` '
        'for this radio group. If the parent state is updated, this could '
        'cause unexpected behavior. To fix this, either include a `key` or a '
        '`controller` for this radio group, and make sure they will not be '
        'updated when the parent state is updated.',
        stackTrace: StackTrace.current,
      );
    }
  }
}