小编典典

隐藏滚动条上的Appbar?

flutter

考虑这个图像。如您所见,它具有一个应用程序栏,而该应用程序栏具有“选项卡式”按钮。我正在尝试对应用
栏进行动画处理,以使其在向上滚动时隐藏,并且仅显示“选项卡按钮”,而在向上滚动时不显示应用栏。请
帮帮我。对不起英语不好而不不是美国人我不是英语


阅读 357

收藏
2020-08-13

共1个答案

小编典典

如果我对您的理解正确,以下代码应可使应用程序栏在滚动时隐藏,而TabBar仍可见:

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

示例来自于。这篇文章.

2020-08-13