如何在SilverAppBar中仅显示TabView

时间:2019-02-05 00:13:28

标签: flutter tabbar tabview nestedscrollview flutter-appbar

我基本上希望在页面中间有一个TabView导航。 为此,我在NestedScrollView中使用了SliverAppBar。 我的SliverAppBar仅由我的TabView组成,我将TabView包裹在SliverAppBar中,以便使用固定的:真正的礼节。

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,
        ),
      ),
    );

它能解决问题,我的问题是我想隐藏/删除包裹了TabBar的SliverAppBar:

enter image description here

1 个答案:

答案 0 :(得分:0)

我需要将expandHeight设置为0:

返回脚手架(       appBar:AppBar(         标题:Text('Title'),       ),       正文:NestedScrollView(

main.cpp: In function ‘int args_parse_cmd_line(int, char**)’:
<command-line>:0:10: error: ‘FIL’ was not declared in this scope
main.cpp:72:114: note: in expansion of macro ‘MYBRANCH’
 %s\n", APPNAME, MAJOR_VERSION, MINOR_VERSION, PATCH_VERSION, BUILD_NUMBER, MYBRANCH);
                                                                            ^~~~~~~~