ListPreference: Make the dialog a bit prettier

This commit is contained in:
Vishesh Handa
2020-05-08 12:09:04 +02:00
parent 6dbc372cac
commit d86e8124e8

View File

@ -27,8 +27,8 @@ class ListPreference extends StatelessWidget {
builder: (BuildContext context) {
var children = <Widget>[];
for (var o in options) {
var tile = RadioListTile<String>(
title: Text(o),
var tile = LabeledRadio(
label: o,
value: o,
groupValue: currentOption,
onChanged: (String val) {
@ -39,10 +39,9 @@ class ListPreference extends StatelessWidget {
}
return AlertDialog(
title: Text(title),
content: SingleChildScrollView(
child: ListBody(
content: Column(
children: children,
),
mainAxisSize: MainAxisSize.min,
),
actions: <Widget>[
FlatButton(
@ -97,3 +96,36 @@ class ProListTile extends StatelessWidget {
);
}
}
class LabeledRadio extends StatelessWidget {
const LabeledRadio({
this.label,
this.groupValue,
this.value,
this.onChanged,
});
final String label;
final String groupValue;
final String value;
final Function onChanged;
@override
Widget build(BuildContext context) {
return InkWell(
onTap: () {
if (value != groupValue) onChanged(value);
},
child: Row(
children: <Widget>[
Radio<String>(
groupValue: groupValue,
value: value,
onChanged: onChanged,
),
Text(label),
],
),
);
}
}