flutter - 如何让 SliverAppBar 在 sub_page 的 SliverList 之前滚动
问题描述
当我 scoll 时,我希望可以SliverAppBar
先滚动。我该怎么做?现在先sub_page。
预期效果:在滚动动作中,首选项是SliverAppBar
. SliverAppBar
显示/隐藏后,继续滚动sub_page。演示(https://github.com/fanybook/cornerstone/blob/master/_docs/flutter_improve_scroll_priority.mp4?raw=true)
关键是有子页面(和底部导航栏)。如果单页可以通过多个 SliverAppBar/bottom 和 NestedScrollView 的 body/SliverList 实现。
解决方案
您正在寻找的内容的最小示例 -
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');
}),
),
],
),
),
);
}
推荐阅读
- android - 如果列表为空,如何启用和禁用浮动操作按钮?
- python - read() 不读取文件的内容
- mongodb - 如何删除小于某个日期的mongodb数据
- php - 如何根据 Laravel 中的学生 ID 获得连接的教师人数和科目人数?
- html - html pre标签格式在浏览器中无法正确显示
- c++ - 计算 QTableWidget 所需的确切高度
- vba - 使用带有 Selenium 的 VBA 进行网页抓取
- reactjs - 在 ReactJS 中的 textarea 内标记
- unit-testing - 如何在 Flutter 单元测试中模拟平台
- spring-boot - 使用 Kafka 作为独立库的 spring-boot 云流