简体   繁体   中英

How to do looping using ListView.builder and for in flutter

I am trying to loop my data using for and ListView.builder , here is part of my code

Widget listData(Data myList) {
  List<Check> tab = myList.data.listItem;
  List<Widget> list = new List<Widget>();
  for (var i = 0; i < tab.length; i++) {
    List<User> user= myList.data.listItem[i].detail;
    list.add(Container(
      child: ListView.builder(
          scrollDirection: Axis.vertical,
          itemCount: user.length,
          itemBuilder: (context, index) {
            return Text("check= $i");
          }),
    ));
  }
  return Center(child: new Column(children: list));
}

I have 6 data..but using that code I always get the first data only... the other data doesn't show up in my screen... is there something that I should do to show my all data using ListView.builder and for looping

在此处输入图像描述

Consider giving some height to the Container say some 50 or 100..that will solve your issue..

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM