是否可以在Flutter的一页中创建多个tabBar

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

我需要使用Flutter设计一个屏幕,并且该屏幕包含两个(TabBar / TabView)和一个TabController当我创建两个它时,[]

TabBar(
        controller: _tabController,
        unselectedLabelColor: Colors.black.withOpacity(.2),
        indicatorWeight: 0.1,
        tabs: [
          Tab(
            text: 'INFO',
          ),
          Tab(
            text: 'HISTORY',
          ),
        ],
      ),
      Container(
        width: 21,
        height: 111,
        child: TabBarView(
          controller: _tabController,
          children: [
            Container(
              color: Colors.blue,
            ),
            Container(
              color: Colors.red,
            ),
          ],
        ),
      ),
      SizedBox(height: 12,),
      TabBar(
        controller: _tab2Controller,
        unselectedLabelColor: Colors.black.withOpacity(.2),
        indicatorWeight: 0.1,
        tabs: [
          Tab(
            text: 'INFO',
          ),
          Tab(
            text: 'HISTORY',
          ),
        ],
      ),
      Container(
        width: 21,
        height: 11,
        child: TabBarView(
          controller: _tab2Controller,
          children: [
            Container(
              color: Colors.blue,
            ),
            Container(
              color: Colors.red,
            ),
          ],
        ),
      ),

我需要使用Flutter设计一个屏幕,并且当我创建两个屏幕时,它包含两个带有TabController的(TabBar / TabView),它会折页TabBar(controller:_tabController,...

flutter tabbar tabview
1个回答
0
投票

在TabBarView中,使嵌套的Tabbar成为独立的小部件在下面的演示中,选项卡2具有嵌套的tarbar,TestTab是独立的小部件代码段

© www.soinside.com 2019 - 2024. All rights reserved.