Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 23131

Dart equivalent to Python zip and list comprehension for generating list of widgets from two lists

$
0
0

I want to create a list of widgets MyWidget(categoryName, color) from the following two lists.

  static const _categoryNames = <String>['Length','Area','Volume',  ];  static const _baseColors = <Color>[    Colors.teal,    Colors.orange,    Colors.pinkAccent,  ];

In Python I would use a list comprehension with zip to get the result.

my_widget_list = [MyWidget(categoryName, baseColor) for categoryName, baseColor in zip(_categoryNames, _baseColors)]

Googling for a similar method for Dart did not provide any satisfactory solution.


Viewing all articles
Browse latest Browse all 23131

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>