0

I have simple method like this:

List<Widget> stringsToWidgets( List<String>? a) {
    List<Text> b = [];
    for (var item in a) {
      b.add(Text(item));
    }
    return b;
  }
  Column(children: stringsToWidgets(["1", "2", "3"]));

I have column, and children of it come from this method. How to do it faster in place, without this stringsToWidgets method?

sosnus
  • 968
  • 10
  • 28

1 Answers1

1

Ok, finally I found solution:

Column(
   children:
   for ( var i in ["1", "2", "3"] ) 
      Text(i)
);
Miro
  • 364
  • 1
  • 12
sosnus
  • 968
  • 10
  • 28