我在 Flutter 中有一个 AlertDialog,它通过下拉按钮显示了一些不同的过滤和排序选项。但是,一旦要显示的元素太多,我希望它可以滚动。将 Listview 放入其中会导致 Dropdownbuttons 出现灰色框(参见图片)。我怎样才能得到这个可滚动的?
代码:
showDialog(
context: context,
builder: (BuildContext context){
return Consumer<VillagerFilter>(
builder: (context, filter, _child) {
return AlertDialog(
title: Text(localization.filterTitleFilterSearch),
content: Container(
height: 500,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
//FIlterbereich
Text("Filter:", textAlign: TextAlign.left,),
Row(
children: <Widget>[
Checkbox(value: filter.isFilterObtained(), onChanged: (newIsCaught){filter.setFilterObtained(newIsCaught);}
),
Text(localization.filterLivingHere)
],
),
Row(
children: <Widget>[
Checkbox(value: filter.isFilterFavourite(), onChanged: (newIsCaught){filter.setFilterFavourite(newIsCaught);}
),
Text(localization.filterFavourite)
],
),
//personalityfilter
ListTile(
title:
Text(localization.filterPersonality + " "),
subtitle: DropdownButton<String>(
value: filter.getFilterPersonality(),
onChanged: (String newValue){
filter.setFilterPersonality(newValue);
},
items: [
'-',
localization.filterPersonalityCranky,
localization.filterPersonalityJock,
]
.map<DropdownMenuItem<String>>((String value){
return DropdownMenuItem<String> (
value: value,
child: Text(value)
);
}).toList()
),
),
//Genderfilter
ListTile(
title:
Text(localization.gender + " "),
subtitle: DropdownButton<String>(
value: filter.getFilterGender(),
onChanged: (String newValue){
filter.setFilterGender(newValue);
},
items: [
'-',
localization.male,
localization.female,
]
.map<DropdownMenuItem<String>>((String value){
return DropdownMenuItem<String> (
value: value,
child: Text(value)
);
}).toList()
),
),
],
),
),
elevation: 24,
backgroundColor: nookDefaultBackgroundColor,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(25.0))
),
actions: <Widget>[
FlatButton(
child: Text('Okay'),
onPressed: () {
Navigator.of(context).pop();
},
),
],
);
}
);
},
);