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) { builder: (BuildContext context) {
var children = <Widget>[]; var children = <Widget>[];
for (var o in options) { for (var o in options) {
var tile = RadioListTile<String>( var tile = LabeledRadio(
title: Text(o), label: o,
value: o, value: o,
groupValue: currentOption, groupValue: currentOption,
onChanged: (String val) { onChanged: (String val) {
@ -39,10 +39,9 @@ class ListPreference extends StatelessWidget {
} }
return AlertDialog( return AlertDialog(
title: Text(title), title: Text(title),
content: SingleChildScrollView( content: Column(
child: ListBody( children: children,
children: children, mainAxisSize: MainAxisSize.min,
),
), ),
actions: <Widget>[ actions: <Widget>[
FlatButton( 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),
],
),
);
}
}