Render list flutter
Ngày đăng:
28/02/2022
Trả lời:
0
Lượt xem:
25
Iterating through a list to render multiple widgets in Flutter?Basically when you hit 'return' on a function the function will stop and will not continue your iteration, so what you need to do is put it all on a list and then add it as a children of a widget you can do something like this: Widget getTextWidgets(Listor even better, you can use .map() operator and do something like this: It is now possible to achieve that in Flutter 1.5 and Dart 2.3 by using a for element in your collection. var list = ["one", "two", "three", "four"]; child: Column( mainAxisAlignment: MainAxisAlignment.center, children:This will display four Text widgets containing the items in the list. The Dart language has aspects of functional programming, so what you want can be written concisely as: Read this as "take each name in list and map it to a Text and form them back into a List". |