我正在堆叠小部件,并且我希望它可以滚动,所以我使用了列表视图,并且遇到了此错误(constraints.hasBoundedHeight':不是真正的抖动),我看到某个地方无法将列表视图放置在列表视图中,所以我进行了更改它到列,但我仍然遇到相同的错误。下面是我的代码。谢谢。
ListView homeList(){
var listView = ListView(
shrinkWrap: true,
children: <Widget>[
_imageSlider(),
Padding(
padding: EdgeInsets.only(top: 15.0, bottom: 15.0, left: 15.0),
child: Text("Trending", style: TextStyle(color: Colors.white, fontSize: 15.0),),
),
Container(
child: FutureBuilder(
future: _trendingListImages(),
builder: (BuildContext context, AsyncSnapshot async){
if(async.data == null){
return ColorLoader3(
radius: 20.0,
dotRadius: 5.0,
);
}else{
return ListView.builder(
shrinkWrap: true,
scrollDirection: Axis.horizontal,
itemCount: async.data.length,
itemBuilder: (BuildContext context, int position) {
return Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Card(
elevation: 18.0,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(10.0))),
child: Image.network(
"http://image.tmdb.org/t/p/w500/"+async.data[position].backdropPath,
fit: BoxFit.cover,
height: 200.0,
width: 130.0,
),
clipBehavior: Clip.antiAlias,
margin: EdgeInsets.all(8.0),
),
Text(
async.data[position].title,
style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.bold),
)
],
);
});
}
}
),
)
],
);
return listView;}
答案 0 :(得分:1)
对我来说,只是用一个容器包装CustomScrollView或ListView。像这样:
Container(
margin: EdgeInsets.all(5.0),
height: 295.0,
width: 333.0,
child: CustomScrollView(),
),
答案 1 :(得分:0)
因此,我最终通过将futurebuilder封闭在容器中并为容器指定了宽度和高度,然后将其添加到列表视图中来解决了此特定方法的问题 这是
下面的代码 Widget _featuredListHorizontal() {
return Container(
margin: EdgeInsets.symmetric(vertical: 20.0),
height: 300.0,
child: FutureBuilder(
future: _trendingListImages(),
builder: (BuildContext context, AsyncSnapshot listData) {
if (listData == null) {
return ColorLoader3(
radius: 20.0,
dotRadius: 5.0,
);
} else {
return ListView.builder(
shrinkWrap: true,
physics: ClampingScrollPhysics(),
scrollDirection: Axis.horizontal,
itemCount: listData.data.length,
itemBuilder: (BuildContext context, int position) {
return Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Card(
elevation: 18.0,
shape: RoundedRectangleBorder(
borderRadius:
BorderRadius.all(Radius.circular(10.0))),
child: Image.network(
"http://image.tmdb.org/t/p/w500/" +
listData.data[position].backdropPath,
fit: BoxFit.cover,
height: 200.0,
width: 230.0,
),
clipBehavior: Clip.antiAlias,
margin: EdgeInsets.all(8.0),
),
Text(
listData.data[position].title,
style: TextStyle(
fontSize: 12.0, fontWeight: FontWeight.bold, color: Colors.white),
),
],
);
});
}
}));
}