Flutter 颤振:修复了一个页面中的小部件和列表视图
我做了一个项目在颤振,我有一个下拉菜单,在菜单下,我将有一个列表视图,但我得到了一个错误。但是,当我只有listview或Dropdownmenu时,它可以工作,但不能同时工作 代码如下:Flutter 颤振:修复了一个页面中的小部件和列表视图,flutter,flutter-layout,Flutter,Flutter Layout,我做了一个项目在颤振,我有一个下拉菜单,在菜单下,我将有一个列表视图,但我得到了一个错误。但是,当我只有listview或Dropdownmenu时,它可以工作,但不能同时工作 代码如下: class _ListViewRound extends State<ListViewRound> { String dropdownValue = 'Runde 1'; @override Widget build(BuildContext context) { retur
class _ListViewRound extends State<ListViewRound> {
String dropdownValue = 'Runde 1';
@override
Widget build(BuildContext context) {
return Column(
children: <Widget>[
DropdownButton<String>(
value: dropdownValue,
onChanged: (String newValue) {
setState(() {
dropdownValue = newValue;
});
},
items: <String>['Runde 1','Runde 2','Runde 3','Runde 4','Runde 5','Runde 6','Runde 7']
.map<DropdownMenuItem<String>>((String value) {
return DropdownMenuItem<String>(
value: value,
child: Text(value),
);
}).toList(),
),
Container(
child: ListView.builder(
itemCount: playID.length,
itemBuilder: (BuildContext context, int index) {
return ListTile(
title: Text(firstPlayer[index] + '-' + secondPlayer[index]),
onTap: () {
showSnackBar(context, playID[index]);
},
);
},
),
),
],
);
}
在
ListView.builder
内部,使用shrinkWrap:true
在ListView.builder
内部,使用shrinkWrap:true在展开的小部件中包装您的ListView
Expanded(
child: ListView.builder(
},
),
),
将您的列表视图
包装在扩展的小部件中
Expanded(
child: ListView.builder(
},
),
),