fix select list value context

This commit is contained in:
niuhuan 2022-03-01 20:00:27 +08:00
parent 6d033ed7db
commit 99dd7dbe19
1 changed files with 16 additions and 15 deletions

View File

@ -97,26 +97,27 @@ List<T> filteredList<T>(List<T> list, bool Function(T) filter) {
Future<T?> chooseListDialog<T>(
BuildContext context, String title, List<T> items,
{String? tips}) async {
List<Widget> widgets = [];
if (tips != null) {
widgets.add(Container(
padding: EdgeInsets.fromLTRB(15, 5, 15, 15),
child: Text(tips),
));
}
widgets.addAll(items.map((e) => SimpleDialogOption(
onPressed: () {
Navigator.of(context).pop(e);
},
child: Text('$e'),
)));
return showDialog<T>(
context: context,
builder: (BuildContext context) {
return SimpleDialog(
title: Text(title),
children: widgets,
children: [
...items.map((e) => SimpleDialogOption(
onPressed: () {
Navigator.of(context).pop(e);
},
child: Text('$e'),
)),
...tips != null
? [
Container(
padding: const EdgeInsets.fromLTRB(15, 5, 15, 15),
child: Text(tips),
),
]
: [],
],
);
},
);