【发布时间】:2020-09-30 09:41:48
【问题描述】:
我是 Flutter 的新手,我有一个行列表,这些行是列表视图的一部分,其中包含列表中的字符串,我想在列表视图顶部添加一个单独的标题以放置不同的内容,但我由于 listview 与 futureBuilder 相结合而不断出现错误,我应该添加什么样的代码?
`body: FutureBuilder<Album>(
future: futureAlbum,
builder: (context, AsyncSnapshot snapshot) {
if (snapshot.hasData) {
return Container(
child: ListView.builder(
itemBuilder: (context, index) {
return Card(
child: Container(
width: double.infinity,
padding: EdgeInsets.all(5),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Container(
padding: EdgeInsets.all(10),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
_sell[index]["text"],
style: TextStyle(fontSize: 20),
),
Text(
(snapshot.data.sellprice[index]).toString(),
style: TextStyle(fontSize: 20,color:Colors.grey),
),
],
),
),
Container(
padding: EdgeInsets.all(10),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
_buy[index]["text"],
style: TextStyle(fontSize: 20),
),
Text(
_buy[index]["symbol"],
style: TextStyle(
fontSize: 20, color: Colors.grey),
),
],
),
),
Container(
padding: EdgeInsets.all(10),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
_currency[index]["text"],
style: TextStyle(fontSize: 17),
),
Text(
_currency[index]["symbol"],
style: TextStyle(
fontSize: 17, color: Colors.grey),
),
],
),
),
Container(
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Image.asset(
_picture[index],
height: 50,
width: 50,
),
],
),
),
],
),
),);
},
itemCount: 7),
`
【问题讨论】: