1

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

6
  • Can you attach a picture of what you achieved so far..that would make it easier to understand your problem easily.. Commented May 22, 2020 at 6:53
  • I have edited my question... tab.length in my code is 3 but I only get first looping and the result is in the picture inside my question Commented May 22, 2020 at 7:08
  • Where are you calling listData..? Commented May 22, 2020 at 7:11
  • @override Widget build(BuildContext context) { return listData(); } Commented May 22, 2020 at 7:14
  • 1
    Try to give some height to the Container that you mentioned in the question..say some 50 or 100.. not sure if it works.. just give it a try.. Commented May 22, 2020 at 7:18

1 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.