我如何使用api response (字符串数组)在flutter中填充TabBar,而不是像这样的硬编码文本。
TabBar(
isScrollable: true,
tabs: [
Tab(
text: 'text1',
),
Tab(
text: 'text2',
),
Tab(
text: 'text3',
),
],
发布于 2019-09-26 19:57:10
您可以对动态TabBar使用以下代码
TabBar(
isScrollable: true,
tabs: List<Widget>.generate(
apiResponse.length,
(int index) {
return Container(
child: new Tab(
child: Text("Api Response $index"),
),
);
},
),
);
https://stackoverflow.com/questions/58115273
复制相似问题