Dart: mapping a list (list.map)
you can use
moviesTitles.map((title) => Tab(text: title)).toList()
example:
bottom: new TabBar(
controller: _controller,
isScrollable: true,
tabs:
moviesTitles.map((title) => Tab(text: title)).toList()
,
),
I'm new to flutter. I found that one can also achieve it this way.
tabs: [
for (var title in movieTitles) Tab(text: title)
]
Note: It requires dart sdk version to be >= 2.3.0, see here
Yes, You can do it this way too
List<String> listTab = new List();
map.forEach((key, val) {
listTab.add(val);
});
//your widget//
bottom: new TabBar(
controller: _controller,
isScrollable: true,
tabs: listTab
,
),