Hide Appbar on Scroll Flutter?

后端 未结 4 799
不知归路
不知归路 2020-12-07 17:21

Consider this image. As you can see it has an appbar and the appbar has Tabbed buttons. Am trying to animate the appbar so that it hides on scrollup and leaves only

4条回答
  •  一向
    一向 (楼主)
    2020-12-07 17:44

    If I understood you correctly, following code should make the app bar hide on scroll while TabBar remains visible:

    new Scaffold(
      body: new NestedScrollView(
        controller: _scrollViewController,
        headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
          return [
            new SliverAppBar(
              title: new Text(widget.title),
              pinned: true,
              floating: true,
              forceElevated: innerBoxIsScrolled,
              bottom: new TabBar(
                tabs: [
                  new Tab(text: "STATISTICS"),
                  new Tab(text: "HISTORY"),
                ],
                controller: _tabController,
              ),
            ),
          ];
        },
        body: new TabBarView(
          children: [
            new StatisticsPage(),
            new HistoryPage(),
          ],
          controller: _tabController,
        ),
      ),
    );
    

    Example coming from this post.

提交回复
热议问题