RadioGroup<T> constructor
RadioGroup<T> ({
- GlobalKey<
RadioGroupState< ? key,T> > - RadioGroupController<
T> ? controller, - required List<
T> values, - Widget labelBuilder(
- T value
- void onChanged(
- T? value
- int indexOfDefault = -1,
- RadioGroupOrientation orientation = RadioGroupOrientation.vertical,
- 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,
);
}
}
}