当列表在颤动中很大时如何使选项卡栏可滚动

问题描述 投票:0回答:1

我使用 DefaultTabController 作为选项卡视图,但我有很多选项卡来过滤数据,但它不滚动,而且我看不到选项卡的文本

如何使其可滚动以便可以正确查看所有选项卡

 Widget build(BuildContext context) {
    final list = ['Furniture', 'Clothe', 'Mobiles', 'Laptop','Accessories','Stationary',];
    return DefaultTabController(
        length: list.length,
        child: Scaffold(
          appBar: AppBar(
            bottom: TabBar(
              tabs: list
                  .map((e) => Tab(
                        text: e,
                      ),
              )
                  .toList(),
            ),
          ),
          body: TabBarView(
            children: list.map((e) => CustomScreen(string: e)).toList(),
          ),
        ));
  }

flutter
1个回答
0
投票

您可以在 Tabbar 中将 isScrollable 添加为 true :

TabBar(
   isScrollable: true,
   ...
),
© www.soinside.com 2019 - 2024. All rights reserved.