请问我如何使用抖动来获得上述图像。在卡片视图下方带有文本的卡片视图,然后将其放入水平listview.builder中,以填充数据。
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 Card(
child: ListTile(
title:Image.network(
"http://image.tmdb.org/t/p/w500/"+async.data[position].backdropPath,),
subtitle: Text(async.data[position].title),
)
);
}
);
}
}
),
)
],
);
return listView;
}
这是我尝试过的方法,但似乎无法正常工作,我尝试了几个小时似乎都无法正确执行。非常感谢您的帮助。
答案 0 :(得分:1)
您需要修改ListView.builder
,使用-Column
示例代码-您可以对其进行修改以匹配您的字段
return ListView.builder(
shrinkWrap: true,
scrollDirection: Axis.horizontal,
itemCount: 25,
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(
'https://placeimg.com/640/480/any',
fit: BoxFit.cover,
height: 200.0,
width: 130.0,
),
clipBehavior: Clip.antiAlias,
margin: EdgeInsets.all(8.0),
),
Text(
'Film Title',
style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.bold),
)
],
);
});