Dart 约束。hasBoundedHeight';:这不是真正的颤振
我正在堆叠小部件,我希望它可以滚动,所以我使用了listview,我得到了这个错误(constraints.hasBoundedHeight:“不是真正的颤振”),我看到listview无法放置在listview中,所以我将其更改为Column,但我仍然得到了相同的错误。下面是我的代码。谢谢Dart 约束。hasBoundedHeight';:这不是真正的颤振,dart,flutter,Dart,Flutter,我正在堆叠小部件,我希望它可以滚动,所以我使用了listview,我得到了这个错误(constraints.hasBoundedHeight:“不是真正的颤振”),我看到listview无法放置在listview中,所以我将其更改为Column,但我仍然得到了相同的错误。下面是我的代码。谢谢 ListView homeList(){ var listView = ListView( shrinkWrap: true, children: <Widget>[ _imag
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;}
ListView主页列表(){
var listView=listView(
收缩膜:对,
儿童:[
_imageSlider(),
填充物(
填充:仅限边缘设置(顶部:15.0,底部:15.0,左侧:15.0),
子项:文本(“趋势”,样式:TextStyle(颜色:Colors.white,fontSize:15.0)),
),
容器(
孩子:未来建设者(
未来:_trendingListImages(),
生成器:(BuildContext上下文,异步快照){
if(async.data==null){
返回颜色加载程序3(
半径:20.0,
点半径:5.0,
);
}否则{
返回ListView.builder(
收缩膜:对,
滚动方向:轴水平,
itemCount:async.data.length,
itemBuilder:(构建上下文,int位置){
返回列(
crossAxisAlignment:crossAxisAlignment.center,
mainAxisSize:mainAxisSize.min,
儿童:[
卡片(
标高:18.0,
形状:圆形矩形边框(
borderRadius:borderRadius.all(半径.圆形(10.0)),
孩子:Image.network(
"http://image.tmdb.org/t/p/w500/“+async.data[position]。backdropPath,
适合:BoxFit.cover,
高度:200.0,
宽度:130.0,
),
clipBehavior:Clip.antiAlias,
边距:所有边集(8.0),
),
正文(
async.data[position].title,
样式:TextStyle(fontSize:20.0,fontWeight:fontWeight.bold),
)
],
);
});
}
}
),
)
],
);
返回listView;}
因此,我最终通过执行以下操作解决了此特定方法的问题:
FutureBuilder
封装在容器中李>
列表视图
Widget\u featuredListHorizontal(){
返回容器(
边距:常数边集。对称(垂直:20.0),
高度:300.0,
孩子:未来建设者(
未来:_trendingListImages(),
生成器:(BuildContext上下文,AsyncSnapshot listData){
if(listData==null){
返回颜色加载程序3(
半径:20.0,
点半径:5.0,
);
}否则{
返回ListView.builder(
收缩膜:对,
物理:ClampingScrollPhysics(),
滚动方向:轴水平,
itemCount:listData.data.length,
itemBuilder:(构建上下文,int位置){
返回列(
crossAxisAlignment:crossAxisAlignment.center,
mainAxisSize:mainAxisSize.min,
儿童:[
卡片(
标高:18.0,
形状:const RoundedRectangleBorder(
边界半径:
边界半径所有(半径圆形(10.0)),
clipBehavior:Clip.antiAlias,
边距:所有常数边集(8.0),
孩子:Image.network(
"http://image.tmdb.org/t/p/w500/${listData.data[position].backdropPath}“,
适合:BoxFit.cover,
高度:200.0,
宽度:230.0,
),
),
正文(
listData.data[position].title,
样式:TextStyle(
字体大小:12.0,
fontWeight:fontWeight.bold,
颜色:颜色。白色),
),
],
);
},
);
}
},
),
);
}
对于我来说,只是用一个容器包装CustomScrollView或ListView。像这样:
Container(
margin: EdgeInsets.all(5.0),
height: 295.0,
width: 333.0,
child: CustomScrollView(),
),