Skip to content

Instantly share code, notes, and snippets.

@zohaib304
Created March 27, 2021 02:08
Show Gist options
  • Save zohaib304/6da5016988c9076d2b271ebb23950e16 to your computer and use it in GitHub Desktop.
Save zohaib304/6da5016988c9076d2b271ebb23950e16 to your computer and use it in GitHub Desktop.
Iterating through a list to render multiple widgets in Flutter
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