Created
March 27, 2021 02:08
-
-
Save zohaib304/6da5016988c9076d2b271ebb23950e16 to your computer and use it in GitHub Desktop.
Iterating through a list to render multiple widgets in Flutter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Widget getTextWidgets(List<String> strings) | |
{ | |
List<Widget> list = new List<Widget>(); | |
for(var i = 0; i < strings.length; i++){ | |
list.add(new Text(strings[i])); | |
} | |
return new Row(children: list); | |
} | |
// or | |
Widget getTextWidgets(List<String> strings) | |
{ | |
return new Row(children: strings.map((item) => new Text(item)).toList()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment