array arr = [MenuItem1, MenuItem2, MenuItem3]
class MenuItem{
String desc;
String id;
}
For the above class and array, how would I present them as a dynamic list flutter?
Rows of Row(chidren[Text((desc),Text((id)])
;
After Dart 2.3 you can use Collection For:
return Row(children:
[for (MenuItem item in arr ) Text(item.desc)]
);
Since you want to return 2 Widgets for each item in the array, you can combine this with the Spread operator:
return Row(children:
[for (MenuItem item in arr ) ...[Text(item.desc),Text(item.id)]]
);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With