当我滚动时,我希望可以先滚动 SliverAppBar
。
我该怎么做?现在是 sub_page 第一。
预期效果:
在滚动操作中,首选项是 SliverAppBar
。 SliverAppBar
显示/隐藏后,继续滚动sub_page。演示(https://github.com/fanybook/cornerstone/blob/master/_docs/flutter_improve_scroll_priority.mp4?raw=true)
重点是有子页面(和 BottomNavigationBar)。如果单页可以通过多个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');
}),
),
],
),
),
);
}
关于flutter - 如何使 SliverAppBar 在 sub_page 的 SliverList 之前滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53863663/