列表循环的原数据
List listViewTabs = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'] ;
list tabs=[{},{},{}];
list tab = ['A','B','C','D','E'}
ListView(
children:tabs.asMap().keys.map((index) {
return ........;
}).toList(),
)
等价于
var ls = tab .map((e) => Text(e)).toList();
ListView(
children:ls ,
)
//以ListView.builder举例,并不代表只有这一种组件
ListView.builder(
itemBuilder: (context, index) {
return .......;
},
itemCount: tabs.length,
),
//这种最适合封装起来做公共组件使用
static List<Widget> _listData(){
List<Widget> list = new List();
for(int i =0;i<20;i++){
list.add(ListTile(
title:Text("$i")
));
}
return list;
}
ListView(
children: <Widget>[
...listview.map(
(e) => Text(e),
)
],
),