@@ -1142,93 +1142,97 @@ class _RadioShowcaseState extends State<RadioShowcase> {
11421142 child: Column (
11431143 crossAxisAlignment: CrossAxisAlignment .start,
11441144 children: < Widget > [
1145- Wrap (
1146- crossAxisAlignment: WrapCrossAlignment .center,
1147- spacing: 8 ,
1148- runSpacing: 8 ,
1149- children: < Widget > [
1150- const SizedBox (width: _width, child: Text ('Enabled' )),
1151- Radio <bool >(
1152- value: true ,
1153- groupValue: groupValue,
1154- onChanged: (bool ? value) {
1155- setState (() {
1156- groupValue = value;
1157- });
1158- },
1159- ),
1160- Radio <bool >(
1161- value: false ,
1162- groupValue: groupValue,
1163- onChanged: (bool ? value) {
1164- setState (() {
1165- groupValue = value;
1166- });
1167- },
1168- ),
1169- ],
1145+ RadioGroup <bool ?>(
1146+ groupValue: groupValue,
1147+ onChanged: (bool ? value) {
1148+ setState (() {
1149+ groupValue = value;
1150+ });
1151+ },
1152+ child: const Wrap (
1153+ crossAxisAlignment: WrapCrossAlignment .center,
1154+ spacing: 8 ,
1155+ runSpacing: 8 ,
1156+ children: < Widget > [
1157+ SizedBox (width: _width, child: Text ('Enabled' )),
1158+ Radio <bool ?>(
1159+ value: true ,
1160+ ),
1161+ Radio <bool ?>(
1162+ value: false ,
1163+ ),
1164+ ],
1165+ ),
11701166 ),
1171- Wrap (
1172- crossAxisAlignment: WrapCrossAlignment .center,
1173- spacing: 8 ,
1174- runSpacing: 8 ,
1175- children: < Widget > [
1176- const SizedBox (width: _width, child: Text ('Disabled' )),
1177- Radio <bool >(
1178- value: true ,
1179- groupValue: groupValue,
1180- onChanged: null ,
1181- ),
1182- Radio <bool >(
1183- value: false ,
1184- groupValue: groupValue,
1185- onChanged: null ,
1186- ),
1187- ],
1167+ RadioGroup <bool ?>(
1168+ groupValue: groupValue,
1169+ onChanged: (bool ? value) {
1170+ setState (() {
1171+ groupValue = value;
1172+ });
1173+ },
1174+ child: const Wrap (
1175+ crossAxisAlignment: WrapCrossAlignment .center,
1176+ spacing: 8 ,
1177+ runSpacing: 8 ,
1178+ children: < Widget > [
1179+ SizedBox (width: _width, child: Text ('Disabled' )),
1180+ Radio <bool ?>(
1181+ value: true ,
1182+ enabled: false ,
1183+ ),
1184+ Radio <bool ?>(
1185+ value: false ,
1186+ enabled: false ,
1187+ ),
1188+ ],
1189+ ),
11881190 ),
1189- Wrap (
1190- crossAxisAlignment: WrapCrossAlignment .center,
1191- spacing: 8 ,
1192- runSpacing: 8 ,
1193- children: < Widget > [
1194- const SizedBox (width: _width, child: Text ('Adaptive' )),
1195- Radio <bool >.adaptive (
1196- value: true ,
1197- groupValue: groupValue,
1198- onChanged: (bool ? value) {
1199- setState (() {
1200- groupValue = value;
1201- });
1202- },
1203- ),
1204- Radio <bool >.adaptive (
1205- value: false ,
1206- groupValue: groupValue,
1207- onChanged: (bool ? value) {
1208- setState (() {
1209- groupValue = value;
1210- });
1211- },
1212- ),
1213- ],
1191+ RadioGroup <bool ?>(
1192+ groupValue: groupValue,
1193+ onChanged: (bool ? value) {
1194+ setState (() {
1195+ groupValue = value;
1196+ });
1197+ },
1198+ child: const Wrap (
1199+ crossAxisAlignment: WrapCrossAlignment .center,
1200+ spacing: 8 ,
1201+ runSpacing: 8 ,
1202+ children: < Widget > [
1203+ SizedBox (width: _width, child: Text ('Adaptive' )),
1204+ Radio <bool ?>.adaptive (
1205+ value: true ,
1206+ ),
1207+ Radio <bool ?>.adaptive (
1208+ value: false ,
1209+ ),
1210+ ],
1211+ ),
12141212 ),
1215- Wrap (
1216- crossAxisAlignment: WrapCrossAlignment .center,
1217- spacing: 8 ,
1218- runSpacing: 8 ,
1219- children: < Widget > [
1220- const SizedBox (width: _width, child: Text ('Disabled' )),
1221- Radio <bool >.adaptive (
1222- value: true ,
1223- groupValue: groupValue,
1224- onChanged: null ,
1225- ),
1226- Radio <bool >.adaptive (
1227- value: false ,
1228- groupValue: groupValue,
1229- onChanged: null ,
1230- ),
1231- ],
1213+ RadioGroup <bool ?>(
1214+ groupValue: groupValue,
1215+ onChanged: (bool ? value) {
1216+ setState (() {
1217+ groupValue = value;
1218+ });
1219+ },
1220+ child: const Wrap (
1221+ crossAxisAlignment: WrapCrossAlignment .center,
1222+ spacing: 8 ,
1223+ runSpacing: 8 ,
1224+ children: < Widget > [
1225+ SizedBox (width: _width, child: Text ('Disabled' )),
1226+ Radio <bool ?>.adaptive (
1227+ value: true ,
1228+ enabled: false ,
1229+ ),
1230+ Radio <bool ?>.adaptive (
1231+ value: false ,
1232+ enabled: false ,
1233+ ),
1234+ ],
1235+ ),
12321236 ),
12331237 ],
12341238 ),
@@ -4673,70 +4677,53 @@ class RadioListTileShowcase extends StatefulWidget {
46734677}
46744678
46754679class _RadioListTileShowcaseState extends State <RadioListTileShowcase > {
4676- int value = 2 ;
4680+ int ? value = 2 ;
46774681 @override
46784682 Widget build (BuildContext context) {
46794683 return RepaintBoundary (
4680- child: Column (
4681- children: < Widget > [
4682- RadioListTile <int >(
4683- secondary: const Icon (Icons .info),
4684- title: const Text ('RadioListTile' ),
4685- subtitle: value == 1
4686- ? const Text ('The radio option is selected' )
4687- : const Text ('The radio option is unselected' ),
4688- value: 1 ,
4689- groupValue: value,
4690- onChanged: (int ? val) {
4691- if (val != null ) {
4692- setState (() {
4693- value = val;
4694- });
4695- }
4696- },
4697- ),
4698- RadioListTile <int >(
4699- secondary: const Icon (Icons .info),
4700- title: const Text ('RadioListTile' ),
4701- subtitle: value == 2
4702- ? const Text ('The radio option is selected' )
4703- : const Text ('The radio option is unselected' ),
4704- value: 2 ,
4705- groupValue: value,
4706- onChanged: (int ? val) {
4707- if (val != null ) {
4708- setState (() {
4709- value = val;
4710- });
4711- }
4712- },
4713- ),
4714- RadioListTile <int >(
4715- secondary: const Icon (Icons .info),
4716- title: const Text ('RadioListTile' ),
4717- subtitle: value == 3
4718- ? const Text ('The radio option and list tile is selected' )
4719- : const Text ('The radio option is unselected' ),
4720- value: 3 ,
4721- groupValue: value,
4722- selected: value == 3 ,
4723- onChanged: (int ? val) {
4724- if (val != null ) {
4725- setState (() {
4726- value = val;
4727- });
4728- }
4729- },
4730- ),
4731- RadioListTile <int >(
4732- secondary: const Icon (Icons .info),
4733- title: const Text ('RadioListTile disabled' ),
4734- subtitle: const Text ('The radio option is unselected and disabled' ),
4735- value: 4 ,
4736- groupValue: value,
4737- onChanged: null ,
4738- ),
4739- ],
4684+ child: RadioGroup <int ?>(
4685+ groupValue: value,
4686+ onChanged: (int ? selectedValue) {
4687+ setState (() {
4688+ value = selectedValue;
4689+ });
4690+ },
4691+ child: Column (
4692+ children: < Widget > [
4693+ RadioListTile <int ?>(
4694+ secondary: const Icon (Icons .info),
4695+ title: const Text ('RadioListTile' ),
4696+ subtitle: value == 1
4697+ ? const Text ('The radio option is selected' )
4698+ : const Text ('The radio option is unselected' ),
4699+ value: 1 ,
4700+ ),
4701+ RadioListTile <int ?>(
4702+ secondary: const Icon (Icons .info),
4703+ title: const Text ('RadioListTile' ),
4704+ subtitle: value == 2
4705+ ? const Text ('The radio option is selected' )
4706+ : const Text ('The radio option is unselected' ),
4707+ value: 2 ,
4708+ ),
4709+ RadioListTile <int ?>(
4710+ secondary: const Icon (Icons .info),
4711+ title: const Text ('RadioListTile' ),
4712+ subtitle: value == 3
4713+ ? const Text ('The radio option and list tile is selected' )
4714+ : const Text ('The radio option is unselected' ),
4715+ value: 3 ,
4716+ selected: value == 3 ,
4717+ ),
4718+ const RadioListTile <int ?>(
4719+ secondary: Icon (Icons .info),
4720+ title: Text ('RadioListTile disabled' ),
4721+ subtitle: Text ('The radio option is unselected and disabled' ),
4722+ value: 4 ,
4723+ enabled: false ,
4724+ ),
4725+ ],
4726+ ),
47404727 ),
47414728 );
47424729 }
0 commit comments