I want to improve the following code snippet by removing the hard coded number 5
(the number of elements in the list). How to do so?
child: TabBar(
tabs: <Widget>[
...List.generate(
5,
(i) => Tab(
child: Text([
'Text',
'Icons',
'Images',
'Simple Form',
'Proper Form'
][i]),
),
),
],
),
Something like
tabs:
'Text/Icons/Images/Simple Form/Proper Form'.split('/').
map((e) => Tab(child: Text(e)).toList();
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句