如何只显示在SilverAppBar的TabView的

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

我基本上喜欢在我的网页中间的TabView的导航。要做到这一点我用了一个SliverAppBar里面NestedScrollView。我SliverAppBar只能由我TabView的组成,我包我的一个SliverAppBar内TabView的才能使用的固定:真礼。

return Scaffold(
      appBar: AppBar(
        title: Text('Title'),
      ),
      body: NestedScrollView(

        headerSliverBuilder: (BuildContext context, bool boxIsScrolled) {
          return <Widget>[
            SliverToBoxAdapter(
                child: Container(
              height: 500,
              color: Colors.red,
            )),

          SliverAppBar(
              pinned: true,
              bottom: TabBar(
                tabs: <Widget>[
                  Tab(
                    text: "Home",
                    icon: Icon(Icons.home),
                  ),
                  Tab(
                    text: "Example page",
                    icon: Icon(Icons.help),
                  )
                ],
                controller: _tabController,
              )),

          ];
        },
        body: TabBarView(
          children: <Widget>[
            PageExample(),
            PageExample(),
          ],
          controller: _tabController,
        ),
      ),
    );

它的伎俩,我的问题是我想隐藏/删除此SliverAppBar那包裹着我的TabBar:

enter image description here

flutter tabbar tabview nestedscrollview flutter-appbar
1个回答
0
投票

我需要expandedHeight设置为0:

返回支架(appBar:AppBar(标题:文本( '标题'),),身体:NestedScrollView(

    headerSliverBuilder: (BuildContext context, bool boxIsScrolled) {
      return <Widget>[
        SliverToBoxAdapter(
            child: Container(
          height: 500,
          color: Colors.red,
        )),

      SliverAppBar(
          expandedHeight: 0,
          pinned: true,
          bottom: TabBar(
            tabs: <Widget>[
              Tab(
                text: "Home",
                icon: Icon(Icons.home),
              ),
              Tab(
                text: "Example page",
                icon: Icon(Icons.help),
              )
            ],
            controller: _tabController,
          )),

      ];
    },
    body: TabBarView(
      children: <Widget>[
        PageExample(),
        PageExample(),
      ],
      controller: _tabController,
    ),
  ),
);
© www.soinside.com 2019 - 2024. All rights reserved.