我真的很喜欢使用 Slivers,但 SliverAppBar 确实有一个问题:通常,我使用 SliverAppBar Widget 来创建一个具有视差效果背景图像的 AppBar。所以我只使用灵活的空间,不幸的是,每当你向下滚动时,它就会被 AppBar 部分挡住。我尝试通过将颜色值设置为透明来使 AppBar 部分透明,但它所做的只是使整个事物(包括弹性空间)透明。
有没有一种方法可以仅使用 SliverAppBar 的弹性空间,而不会在向下滚动时淡入 AppBar 部分?
这是我使用的代码:
SliverAppBar(
expandedHeight: 220,
pinned: false,
forceElevated: true,
backgroundColor: Colors.transparent,
stretch: true,
leading: Container(),
flexibleSpace: FlexibleSpaceBar(
collapseMode: CollapseMode.pin,
background:Stack(
children: <Widget>[
Image(
fit: BoxFit.cover,
width: MediaQuery.of(context).size.width,
image: AssetImage('assets/images/image2.png'),
),
Positioned(
bottom: 0,
child: Container(
height: 110,
width: MediaQuery.of(context).size.width,
color: Colors.grey,
),
),
Positioned(
bottom: 10,
left: 10,
child: CircleAvatar(
radius: 45,
backgroundImage: AssetImage('assets/images/image.png'),
),
),
Positioned(
bottom: 77,
left: 110,
child: Container(
width: …Run Code Online (Sandbox Code Playgroud)