Skip to content

Commit 7bebd68

Browse files
committed
fix: Use radio group for radio buttons
1 parent bf4e558 commit 7bebd68

File tree

1 file changed

+29
-27
lines changed

1 file changed

+29
-27
lines changed

lib/common/component/custom_radio_button_group.dart

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -17,34 +17,36 @@ class CustomRadioButtonGroup<T> extends StatelessWidget {
1717

1818
@override
1919
Widget build(BuildContext context) {
20-
return Column(
21-
children: options.entries.map(
22-
(entry) {
23-
void onOptionClick() {
24-
onOptionSelected(entry.key);
25-
}
26-
27-
return CustomInkWellRoundedRectangle(
28-
cornerRadius: 4,
29-
onClick: onOptionClick,
30-
child: Padding(
31-
padding: const EdgeInsets.symmetric(vertical: 4, horizontal: 8),
32-
child: Row(
33-
children: [
34-
Radio(
35-
value: entry.key,
36-
groupValue: selectedOption,
37-
fillColor: WidgetStateProperty.all(context.colorScheme.primary),
38-
onChanged: (_) => onOptionClick,
39-
),
40-
const SizedBox(width: 12),
41-
CustomText(text: entry.value, style: context.textTheme.labelLarge),
42-
],
20+
return RadioGroup<T>(
21+
groupValue: selectedOption,
22+
onChanged: (value) {
23+
if (value != null) {
24+
onOptionSelected(value);
25+
}
26+
},
27+
child: Column(
28+
children: options.entries.map(
29+
(entry) {
30+
return CustomInkWellRoundedRectangle(
31+
cornerRadius: 4,
32+
onClick: () => onOptionSelected(entry.key),
33+
child: Padding(
34+
padding: const EdgeInsets.symmetric(vertical: 4, horizontal: 8),
35+
child: Row(
36+
children: [
37+
Radio(
38+
value: entry.key,
39+
fillColor: WidgetStateProperty.all(context.colorScheme.primary),
40+
),
41+
const SizedBox(width: 12),
42+
CustomText(text: entry.value, style: context.textTheme.labelLarge),
43+
],
44+
),
4345
),
44-
),
45-
);
46-
},
47-
).toList(),
46+
);
47+
},
48+
).toList(),
49+
),
4850
);
4951
}
5052
}

0 commit comments

Comments
 (0)