我在Flutter中创建一个项目,在其中有一个Dropdownmenu,在菜单下,我将具有一个列表视图,但出现错误。但是,当我只有列表视图或Dropdownmenu时,它将起作用,但不能同时起作用。
代码如下:
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]);
},
);
},
),
),
],
);
}
这是错误:
I/flutter (24219): ══╡ EXCEPTION CAUGHT BY RENDERING LIBRARY ╞═════════════════════════════════════════════════════════
I/flutter (24219): The following assertion was thrown during performResize():
I/flutter (24219): Vertical viewport was given unbounded height.
I/flutter (24219): Viewports expand in the scrolling direction to fill their container.In this case, a vertical
I/flutter (24219): viewport was given an unlimited amount of vertical space in which to expand. This situation
I/flutter (24219): typically happens when a scrollable widget is nested inside another scrollable widget.
I/flutter (24219): If this widget is always nested in a scrollable widget there is no need to use a viewport because
I/flutter (24219): there will always be enough vertical space for the children. In this case, consider using a Column
I/flutter (24219): instead. Otherwise, consider using the "shrinkWrap" property (or a ShrinkWrappingViewport) to size
I/flutter (24219): the height of the viewport to the sum of the heights of its children.
I/flutter (24219): When the exception was thrown, this was the stack:
答案 0 :(得分:0)
在ListView.builder
内,使用shrinkWrap: true
答案 1 :(得分:0)
将您的ISNULL(NULLIF(cast(N'' as nvarchar(max)), N''), 'Ravi')
包装在ListView
小部件中
Expanded