Hide Appbar on Scroll Flutter?

后端 未结 4 800
不知归路
不知归路 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:48

    Using DefaultTabController

    DefaultTabController(
          length: 2,
          child: new Scaffold(
            body: new NestedScrollView(
              headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
                return [
                  new SliverAppBar(
                    title: Text("Application"),
                    floating: true,
                    pinned: true,
                    snap: true,
                    bottom: new TabBar(
                      tabs: [
                        new Tab(text: "T"),
                        new Tab(text: "B"),
                      ], // <-- total of 2 tabs
                    ),
                  ),
                ];
              },
              body: new TabBarView(
                children: [
                  Center(
                      child: Text(
                    'T Tab',
                    style: TextStyle(fontSize: 30),
                  )),
                  Center(
                      child: Text(
                    'B Tab',
                    style: TextStyle(fontSize: 30),
                  )),
                ],
              ),
            ),
          ),
        );
    

    Output:

提交回复
热议问题