How to do looping using ListView.builder and for in flutter
3,939
Consider giving some height to the Container
say some 50 or 100..that will solve your issue..
Author by
uyhaW
Updated on December 20, 2022Comments
-
uyhaW over 1 year
I am trying to loop my data using
for
andListView.builder
, here is part of my codeWidget 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-
srikanth7785 about 4 yearsCan you attach a picture of what you achieved so far..that would make it easier to understand your problem easily..
-
uyhaW about 4 yearsI 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
-
srikanth7785 about 4 yearsWhere are you calling
listData
..? -
uyhaW about 4 years@override Widget build(BuildContext context) { return listData(); }
-
uyhaW about 4 yearsI am calling listData like that.. I am calling it inside my Stateful widget
-
srikanth7785 about 4 yearsTry 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..
-