gpt4 book ai didi

dictionary - flutter : Mapping two lists toegther

转载 作者:行者123 更新时间:2023-12-05 02:15:06 24 4
gpt4 key购买 nike

这里我只映射一个列表,但情况是我想将两个列表映射在一起,以便显示日期,然后显示照片,就像这里的图片一样。所以,我想知道如何制作 list1 和日期的映射,这是我拥有的两个列表。它们将只是我可以在脚手架主体中使用的一个列表? enter image description here

List<Meal> _list1=[Meal(dis:'it is a chicken sandwichh',name: 'chekin filla'),
Meal(dis:'it is a chicken sandwichh',name: 'chekin filla'),
Meal(dis:'it is a chicken sandwichh',name: 'chekin filla'),
Meal(dis:'it is a chicken sandwichh',name: 'chekin filla'),
Meal(dis:'it is a chicken sandwichh',name: 'chekin filla')];
List<Date> dates = [Date(dat:'20th of september 2018'),Date(dat:'21th of september 2018'),Date(dat:'22th of september 2018'),
Date(dat:'23th of september 2018')
,Date(dat: '24th of september 2018')];
Map<Object,Object> list2= {dates,_list1};
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Text('listviewww'),
),
body:
ListView( children:_list2
.map((element){
return Column(
children: <Widget>[
Container(
child: Text('My name is ayaaaaaaaaaaa '),
),
Container(
margin: EdgeInsets.all(9.0),
constraints: new BoxConstraints.expand(height: 300.0),
decoration: new BoxDecoration(
border: new Border.all(color: Colors.blueAccent),
borderRadius: BorderRadius.horizontal( left:Radius.circular(30.0) ,right:Radius.circular(30.0) ),
image: new DecorationImage(image: new AssetImage('assets/food.jpg'),fit: BoxFit.cover,),),
padding: EdgeInsets.only(bottom: 10.0),
child:Center(
child:Text('HELLfffffffffffO')
)
)
],

);
}).toList()

)
);

最佳答案

您不必映射两个列表来创建 ListView。只需使用 ListView.builder()

ListView.builder(
itemBuilder: (context, index) {
var meal = _list1[index];
var date = dates[index];
return Text("Here comes your item with $meal and $date");
},
);

关于dictionary - flutter : Mapping two lists toegther,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52485476/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com