diff --git a/packages/diagrams/lib/src/radio_list_tile.dart b/packages/diagrams/lib/src/radio_list_tile.dart index e1ea2426..70ba1cf1 100644 --- a/packages/diagrams/lib/src/radio_list_tile.dart +++ b/packages/diagrams/lib/src/radio_list_tile.dart @@ -15,17 +15,13 @@ class LinkedLabelRadio extends StatelessWidget { const LinkedLabelRadio({ required this.label, required this.padding, - required this.groupValue, required this.value, - required this.onChanged, super.key, }); final String label; final EdgeInsets padding; - final bool groupValue; final bool value; - final ValueChanged onChanged; @override Widget build(BuildContext context) { @@ -33,13 +29,7 @@ class LinkedLabelRadio extends StatelessWidget { padding: padding, child: Row( children: [ - Radio( - groupValue: groupValue, - value: value, - onChanged: (bool? newValue) { - onChanged(newValue); - }, - ), + Radio(value: value), RichText( text: TextSpan( text: label, @@ -63,37 +53,23 @@ class LabeledRadio extends StatelessWidget { const LabeledRadio({ required this.label, required this.padding, - required this.groupValue, required this.value, - required this.onChanged, super.key, }); final String label; final EdgeInsets padding; - final bool groupValue; final bool value; - final ValueChanged onChanged; @override Widget build(BuildContext context) { return InkWell( - onTap: () { - if (value != groupValue) { - onChanged(value); - } - }, + onTap: () {}, child: Padding( padding: padding, child: Row( children: [ - Radio( - groupValue: groupValue, - value: value, - onChanged: (bool? newValue) { - onChanged(newValue); - }, - ), + Radio(value: value), Text(label), ], ), @@ -127,29 +103,25 @@ class _RadioListTileDiagramState extends State { alignment: FractionalOffset.center, padding: const EdgeInsets.all(5.0), color: Colors.white, - child: Column( - children: [ - RadioListTile( - title: const Text('Lafayette'), - value: SingingCharacter.lafayette, - groupValue: _character, - onChanged: (SingingCharacter? value) { - setState(() { - _character = value; - }); - }, - ), - RadioListTile( - title: const Text('Thomas Jefferson'), - value: SingingCharacter.jefferson, - groupValue: _character, - onChanged: (SingingCharacter? value) { - setState(() { - _character = value; - }); - }, - ), - ], + child: RadioGroup( + groupValue: _character, + onChanged: (SingingCharacter? value) { + setState(() { + _character = value; + }); + }, + child: const Column( + children: [ + RadioListTile( + title: Text('Lafayette'), + value: SingingCharacter.lafayette, + ), + RadioListTile( + title: Text('Thomas Jefferson'), + value: SingingCharacter.jefferson, + ), + ], + ), ), ), ); @@ -161,31 +133,27 @@ class _RadioListTileDiagramState extends State { alignment: FractionalOffset.center, padding: const EdgeInsets.all(5.0), color: Colors.white, - child: Column( - children: [ - LinkedLabelRadio( - label: 'First tappable label text', - padding: const EdgeInsets.symmetric(horizontal: 5.0), - value: true, - groupValue: _isRadioSelected, - onChanged: (bool? newValue) { - setState(() { - _isRadioSelected = newValue!; - }); - }, - ), - LinkedLabelRadio( - label: 'Second tappable label text', - padding: const EdgeInsets.symmetric(horizontal: 5.0), - value: false, - groupValue: _isRadioSelected, - onChanged: (bool? newValue) { - setState(() { - _isRadioSelected = newValue!; - }); - }, - ), - ], + child: RadioGroup( + groupValue: _isRadioSelected, + onChanged: (bool? newValue) { + setState(() { + _isRadioSelected = newValue!; + }); + }, + child: const Column( + children: [ + LinkedLabelRadio( + label: 'First tappable label text', + padding: EdgeInsets.symmetric(horizontal: 5.0), + value: true, + ), + LinkedLabelRadio( + label: 'Second tappable label text', + padding: EdgeInsets.symmetric(horizontal: 5.0), + value: false, + ), + ], + ), ), ), ); @@ -197,31 +165,27 @@ class _RadioListTileDiagramState extends State { alignment: FractionalOffset.center, padding: const EdgeInsets.all(5.0), color: Colors.white, - child: Column( - children: [ - LabeledRadio( - label: 'This is the first label text', - padding: const EdgeInsets.symmetric(horizontal: 5.0), - value: true, - groupValue: _isRadioSelected, - onChanged: (bool? newValue) { - setState(() { - _isRadioSelected = newValue!; - }); - }, - ), - LabeledRadio( - label: 'This is the second label text', - padding: const EdgeInsets.symmetric(horizontal: 5.0), - value: false, - groupValue: _isRadioSelected, - onChanged: (bool? newValue) { - setState(() { - _isRadioSelected = newValue!; - }); - }, - ), - ], + child: RadioGroup( + groupValue: _isRadioSelected, + onChanged: (bool? newValue) { + setState(() { + _isRadioSelected = newValue!; + }); + }, + child: const Column( + children: [ + LabeledRadio( + label: 'This is the first label text', + padding: EdgeInsets.symmetric(horizontal: 5.0), + value: true, + ), + LabeledRadio( + label: 'This is the second label text', + padding: EdgeInsets.symmetric(horizontal: 5.0), + value: false, + ), + ], + ), ), ), );