Skip to content

Commit 6bcf84b

Browse files
committed
migrate all samples to new RadioGroup api
1 parent 21118f8 commit 6bcf84b

File tree

3 files changed

+50
-53
lines changed

3 files changed

+50
-53
lines changed

isolate_example/lib/infinite_process_page.dart

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -78,25 +78,25 @@ class InfiniteProcessPage extends StatelessWidget {
7878
value: !controller.paused,
7979
onChanged: (_) => controller.pausedSwitch(),
8080
activeTrackColor: Colors.lightGreenAccent,
81-
activeColor: Colors.black,
81+
activeThumbColor: Colors.black,
8282
inactiveTrackColor: Colors.deepOrangeAccent,
8383
inactiveThumbColor: Colors.black,
8484
),
8585
const Text('Pause/Resume'),
8686
],
8787
),
88-
Row(
89-
mainAxisAlignment: MainAxisAlignment.center,
90-
children: [
91-
for (int i = 1; i <= 3; i++) ...[
92-
Radio<int>(
93-
value: i,
94-
groupValue: controller.currentMultiplier,
95-
onChanged: (val) => controller.setMultiplier(val!),
96-
),
97-
Text('${i}x'),
88+
RadioGroup(
89+
groupValue: controller.currentMultiplier,
90+
onChanged: (val) => controller.setMultiplier(val!),
91+
child: Row(
92+
mainAxisAlignment: MainAxisAlignment.center,
93+
children: [
94+
for (int i = 1; i <= 3; i++) ...[
95+
Radio<int>(value: i),
96+
Text('${i}x'),
97+
],
9898
],
99-
],
99+
),
100100
),
101101
],
102102
),

material_3_demo/lib/src/component_screen.dart

Lines changed: 24 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -981,35 +981,30 @@ class _RadiosState extends State<Radios> {
981981
return ComponentDecoration(
982982
label: 'Radio buttons',
983983
tooltipMessage: 'Use RadioListTile<T> or Radio<T>',
984-
child: Column(
985-
children: <Widget>[
986-
RadioListTile<Options>(
987-
title: const Text('Option 1'),
988-
value: Options.option1,
989-
groupValue: _selectedOption,
990-
onChanged: (value) {
991-
setState(() {
992-
_selectedOption = value;
993-
});
994-
},
995-
),
996-
RadioListTile<Options>(
997-
title: const Text('Option 2'),
998-
value: Options.option2,
999-
groupValue: _selectedOption,
1000-
onChanged: (value) {
1001-
setState(() {
1002-
_selectedOption = value;
1003-
});
1004-
},
1005-
),
1006-
RadioListTile<Options>(
1007-
title: const Text('Option 3'),
1008-
value: Options.option3,
1009-
groupValue: _selectedOption,
1010-
onChanged: null,
1011-
),
1012-
],
984+
child: RadioGroup(
985+
groupValue: _selectedOption,
986+
onChanged: (value) {
987+
setState(() {
988+
_selectedOption = value;
989+
});
990+
},
991+
child: Column(
992+
children: <Widget>[
993+
RadioListTile<Options>(
994+
title: const Text('Option 1'),
995+
value: Options.option1,
996+
),
997+
RadioListTile<Options>(
998+
title: const Text('Option 2'),
999+
value: Options.option2,
1000+
),
1001+
RadioListTile<Options>(
1002+
title: const Text('Option 3'),
1003+
value: Options.option3,
1004+
enabled: false,
1005+
),
1006+
],
1007+
),
10131008
),
10141009
);
10151010
}

platform_design/lib/widgets.dart

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -303,18 +303,20 @@ void showChoices(BuildContext context, List<String> choices) {
303303
contentPadding: const EdgeInsets.only(top: 12),
304304
content: StatefulBuilder(
305305
builder: (context, setState) {
306-
return Column(
307-
mainAxisSize: MainAxisSize.min,
308-
children: List<Widget>.generate(choices.length, (index) {
309-
return RadioListTile<int?>(
310-
title: Text(choices[index]),
311-
value: index,
312-
groupValue: selectedRadio,
313-
onChanged: (value) {
314-
setState(() => selectedRadio = value);
315-
},
316-
);
317-
}),
306+
return RadioGroup(
307+
groupValue: selectedRadio,
308+
onChanged: (value) {
309+
setState(() => selectedRadio = value);
310+
},
311+
child: Column(
312+
mainAxisSize: MainAxisSize.min,
313+
children: List<Widget>.generate(choices.length, (index) {
314+
return RadioListTile<int?>(
315+
title: Text(choices[index]),
316+
value: index,
317+
);
318+
}),
319+
),
318320
);
319321
},
320322
),

0 commit comments

Comments
 (0)