【发布时间】:2019-09-23 08:00:53
【问题描述】:
我需要有多个 SliverAppBar,每个在一个视图中都有自己的 SliverList。目前只有第一个 SliverAppBar 正确响应。
我当然在 SO 和 Google 上进行过扩展搜索,但还没有找到解决方案!
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Details'),
),
body: CustomScrollView(
slivers: <Widget>[
new SliverAppBar(
floating: true,
automaticallyImplyLeading: false,
title: Text('1'),
),
new SliverList(
delegate: SliverChildBuilderDelegate(
(context, index) => ListTile(title: Text('Text 1')),
childCount: 20,
),
),
new SliverAppBar(
automaticallyImplyLeading: false,
title: Text('2'),
floating: true,
),
new SliverList(
delegate: SliverChildBuilderDelegate(
(context, index) => ListTile(title: Text('Text 2')),
childCount: 20,
),
),
],
),
);
}
如果您滚动,我希望在您滚动列表时看到标题“2”也浮动。
【问题讨论】:
-
谢谢!这正是我一直在寻找的
-
我认为你的问题是相关的。我会正确回答,以便对其他人有用,好吗?