RadioSuperFormField<T>.listTile constructor
RadioSuperFormField<T>.listTile ({
- Key? key,
- required String name,
- required List<
RadioOption< options,T> > - List<
SuperFormFieldRule> ? rules, - bool toggleable = false,
- Color? activeColor,
- Widget subtitle(
- RadioOption<
T> option
- RadioOption<
- bool isThreeLine = false,
- bool? dense,
- Widget? secondary,
- bool selected(
- RadioOption<
T> option
- RadioOption<
- ListTileControlAffinity controlAffinity = ListTileControlAffinity.platform,
- bool autofocus = false,
- EdgeInsetsGeometry? contentPadding,
- ShapeBorder? shape,
- Color? tileColor,
- Color? selectedTileColor,
- void onChanged(
- T? value
- bool? enabled,
Creates a Column of connected RadioListTiles which represent the options.
Check RadioListTile documentation for arguments documentation.
Diffences between RadioListTile and this builder are:
subtitle
is a function so developers can customize it per optionselected
is a function so developers can customize it per option
Implementation
RadioSuperFormField.listTile({
Key? key,
required String name,
required this.options,
List<SuperFormFieldRule>? rules,
bool toggleable = false,
Color? activeColor,
Widget Function(RadioOption<T> option)? subtitle,
bool isThreeLine = false,
bool? dense,
Widget? secondary,
bool Function(RadioOption<T> option)? selected,
ListTileControlAffinity controlAffinity = ListTileControlAffinity.platform,
bool autofocus = false,
EdgeInsetsGeometry? contentPadding,
ShapeBorder? shape,
Color? tileColor,
Color? selectedTileColor,
void Function(T? value)? onChanged,
this.enabled,
}) : super(
key: key,
name: name,
rules: rules ?? [],
builder: (context, fieldState, formState) {
final T? currentGroupValue = fieldState.data?.value as T?;
void effectiveOnChanged(T? value) {
SuperFormFieldData newData = fieldState.data!.copyWithValue(
value: value,
touched: true,
);
// If the field was tried to be submitted it should be now revalidated every change
if (formState.validationMode == ValidationMode.onChange ||
newData.submitted) {
newData = newData.validate(rules ?? []);
}
formState.updateFieldData(newData);
if (onChanged != null) {
onChanged(value);
}
}
final effectiveEnabled = enabled ?? formState.enabled;
return listTileRadioBuilder(
context,
RadioState<T>(
options,
currentGroupValue,
effectiveEnabled ? effectiveOnChanged : null,
fieldState.focusNode,
),
toggleable: toggleable,
activeColor: activeColor,
subtitle: subtitle,
isThreeLine: isThreeLine,
dense: dense,
secondary: secondary,
selected: selected,
controlAffinity: controlAffinity,
autofocus: autofocus,
contentPadding: contentPadding,
shape: shape,
tileColor: tileColor,
selectedTileColor: selectedTileColor,
);
},
);