flutter - 如何使 SliverAppBar 在 sub_page 的 SliverList 之前滚动

标签 flutter flutter-layout

当我滚动时,我希望可以先滚动 SliverAppBar。 我该怎么做?现在是 sub_page 第一。

预期效果: 在滚动操作中,首选项是 SliverAppBarSliverAppBar显示/隐藏后,继续滚动sub_page。演示(https://github.com/fanybook/cornerstone/blob/master/_docs/flutter_improve_scroll_priority.mp4?raw=true)

重点是有子页面(和 BottomNavigationBar)。如果单页可以通过多个SliverAppBar/bottom和NestedScrollView的body/SliverList来实现。

enter image description here

最佳答案

您要查找的内容的最小示例 -

Widget build(BuildContext context) {
    return DefaultTabController(
      length: 3,
      child: Scaffold(
        body: CustomScrollView(
          slivers: <Widget>[
            SliverAppBar(
              title: Text('Demo'),
              pinned: false,

              bottom: PreferredSize(
                  child: TabBar(
                    tabs: <Widget>[
                      Text('Tab 1'),
                      Text('Tab 2'),
                      Text('Tab 3'),
                    ],
                  ),
                  preferredSize: Size.fromHeight(25.0)),
            ),
            SliverList(
              delegate: SliverChildBuilderDelegate((context, int) {
                return Text('Dummy text');
              }),
            ),
          ],
        ),
      ),
    );
  }

enter image description here

关于flutter - 如何使 SliverAppBar 在 sub_page 的 SliverList 之前滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53863663/

相关文章:

flutter - 如何在Android Studio中不运行模拟器/模拟器的情况下运行Dart程序

flutter - 如何在事件时从父级更新 ModalBottomSheet 的内容

animation - 容器高度动画从中间开始

Flutter:动画化容器的边框颜色

android - 我如何在 flutter 中单击交错 GridView 中的项目

android - 三星手机中的 Flutter 构建失败,Permission Denial : broadcast from android asks to run as user -1 but is calling from user 0

在 Xcode 中构建应用程序时出现 Flutter pod 错误

flutter - 在 Flutter 的嵌套导航中输入焦点

tensorflow - 资源无法调用关闭 -flutter/tflite 错误

button - 使用 slider 按钮创建分段控件小部件-Flutter