I have this data:
[{ID: 0, Line: 100, Part: 00-87000088, Lots: 00865756,00866790,00868501,00871385,00871905,00872712,00875997,00878042}, {ID: 1, Line: 990000, Part: 00-87000001, Lots: 00746727,00748270,00750627,00750632,00753983,00754156,00757423,00758997,00762736,00792476}]
I need to display this in a scrollable widget like this:
Line Part Lots
100 00-87000088 00865756
00866790
00868501
00871385
00871905
00872712
00875997
00878042
990000 00-87000001 00746727
00748270
00750627
00750632
00753983
00754156
00757423
00758997
00762736
00792476
The list of lots could be pretty long, that’s why it needs to be scrollable. And the list of lots is dynamic, so I don’t know the list ahead of time. How do I do this?
What I’ve tried:
//Populating the variables with data:
List<Map<dynamic, dynamic>> lotsPicked = [];
var lines = [];
var parts = [];
var lots = [];
lotsPicked = await globals.issuePartsGetLots(wo: wo);
for (var element in lotsPicked) {
lines.add(element['Line']);
parts.add(element['Part']);
lots.add(element['Lots']);
}
//Showing the data:
ListView.builder(
itemCount: lotsPicked.length,
itemBuilder: (BuildContext context, int index) {
return Column(
children: [
Text(lines[index].toString()),
Text(parts[index].toString()),
Text(lots[index].toString()),
],
);
return Text(lotsPicked[index]['Line'].toString());
},
)
2
Answers
You can achieve this using ListView.builder Here is the code:
You can create a itemBuilder for this.
And for the header include extend one item