radioButtonFormEntry<T> method
Widget
radioButtonFormEntry<
T>({ - String title = 'Radio Selection',
- String subTitle = 'Choose one option',
- required List<T> options,
- required String getDisplayText(
- T
),
- required dynamic onChanged(
- T?
),
- T? defaultValue,
- String? validator(
- T?
)?,
- bool isRequired = false,
})
Implementation
Widget radioButtonFormEntry<T>({
String title = 'Radio Selection',
String subTitle = 'Choose one option',
required List<T> options,
required String Function(T) getDisplayText,
required Function(T?) onChanged,
T? defaultValue,
String? Function(T?)? validator,
bool isRequired = false,
}) {
if (options.isEmpty) {
throw ArgumentError('Options list cannot be empty');
}
return formEntry(
title: title,
subTitle: subTitle,
inputWidget: Column(
children: options.map((T option) {
return RadioListTile<T>(
title: Text(
getDisplayText(option),
style: const TextStyle(
color: Colors.black87,
fontSize: 16,
fontWeight: FontWeight.w400,
),
),
value: option,
groupValue: defaultValue,
activeColor: Colors.blue,
onChanged: isEdit
? (T? value) {
onChanged(value);
widget.formKey.currentState?.save();
widget.onModified?.call();
}
: null,
);
}).toList(),
),
);
}