本文介绍了垂直视口被赋予了无限的高度误差的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
@override
Widget build(BuildContext context) {
return Column(
children: <Widget>[
new Text("Some text"),
ListView()
],
);
}
Widget ListView() {
return ListView(
padding: EdgeInsets.symmetric(vertical: 8.0),
children: Item(),
);
}
List<Item> Item() {
return list
.map((item) => Item(text: item))
.toList();
}
class Item extends ListTile {
Item({String text, GestureTapCallback onTap})
: super(subtitle: Column(children: <Widget>[
Text(text),
]));
}
屏幕上出现空白,控制台显示:
A blank space appears on the screen and the console says:
垂直视口的高度不受限制.视口在 滚动方向以填充其容器.
Vertical viewport was given unbounded height. Viewports expand in the scrolling direction to fill their container.
推荐答案
在Flex中包装ListView将使其正常工作.
Wrapping ListView inside Flexible will make it work.
Widget ListView() {
return new Flexible(child: new ListView(
padding: new EdgeInsets.symmetric(vertical: 8.0),
children: Item()));
}
这篇关于垂直视口被赋予了无限的高度误差的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!