wahyu
wahyu

Reputation: 2405

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

enter image description here

Upvotes: 1

Views: 5152

Answers (1)

srikanth7785
srikanth7785

Reputation: 1522

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

Upvotes: 2

Related Questions