Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
164 changes: 64 additions & 100 deletions packages/diagrams/lib/src/radio_list_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,31 +15,21 @@ 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<bool?> onChanged;

@override
Widget build(BuildContext context) {
return Padding(
padding: padding,
child: Row(
children: <Widget>[
Radio<bool>(
groupValue: groupValue,
value: value,
onChanged: (bool? newValue) {
onChanged(newValue);
},
),
Radio<bool>(value: value),
RichText(
text: TextSpan(
text: label,
Expand All @@ -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<bool?> onChanged;

@override
Widget build(BuildContext context) {
return InkWell(
onTap: () {
if (value != groupValue) {
onChanged(value);
}
},
onTap: () {},
child: Padding(
padding: padding,
child: Row(
children: <Widget>[
Radio<bool>(
groupValue: groupValue,
value: value,
onChanged: (bool? newValue) {
onChanged(newValue);
},
),
Radio<bool>(value: value),
Text(label),
],
),
Expand Down Expand Up @@ -127,29 +103,25 @@ class _RadioListTileDiagramState extends State<RadioListTileDiagram> {
alignment: FractionalOffset.center,
padding: const EdgeInsets.all(5.0),
color: Colors.white,
child: Column(
children: <Widget>[
RadioListTile<SingingCharacter>(
title: const Text('Lafayette'),
value: SingingCharacter.lafayette,
groupValue: _character,
onChanged: (SingingCharacter? value) {
setState(() {
_character = value;
});
},
),
RadioListTile<SingingCharacter>(
title: const Text('Thomas Jefferson'),
value: SingingCharacter.jefferson,
groupValue: _character,
onChanged: (SingingCharacter? value) {
setState(() {
_character = value;
});
},
),
],
child: RadioGroup<SingingCharacter?>(
groupValue: _character,
onChanged: (SingingCharacter? value) {
setState(() {
_character = value;
});
},
child: const Column(
children: <Widget>[
RadioListTile<SingingCharacter>(
title: Text('Lafayette'),
value: SingingCharacter.lafayette,
),
RadioListTile<SingingCharacter>(
title: Text('Thomas Jefferson'),
value: SingingCharacter.jefferson,
),
],
),
),
),
);
Expand All @@ -161,31 +133,27 @@ class _RadioListTileDiagramState extends State<RadioListTileDiagram> {
alignment: FractionalOffset.center,
padding: const EdgeInsets.all(5.0),
color: Colors.white,
child: Column(
children: <Widget>[
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<bool>(
groupValue: _isRadioSelected,
onChanged: (bool? newValue) {
setState(() {
_isRadioSelected = newValue!;
});
},
child: const Column(
children: <Widget>[
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,
),
],
),
),
),
);
Expand All @@ -197,31 +165,27 @@ class _RadioListTileDiagramState extends State<RadioListTileDiagram> {
alignment: FractionalOffset.center,
padding: const EdgeInsets.all(5.0),
color: Colors.white,
child: Column(
children: <Widget>[
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<bool?>(
groupValue: _isRadioSelected,
onChanged: (bool? newValue) {
setState(() {
_isRadioSelected = newValue!;
});
},
child: const Column(
children: <Widget>[
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,
),
],
),
),
),
);
Expand Down