【发布时间】:2021-03-14 10:23:31
【问题描述】:
我使用FlexibleSpaceBar,但仅用于图像。 AppBar 始终位于顶部,因此这两个元素之间根本没有过渡,只是使用 parallax 向上滚动图像的效果。
所以我不需要为图像制作不透明效果。
我知道这是可能的,因为我在 Aliexpress 的应用程序上看到了它,我知道它使用了 Flutter。您可以在此处看到无不透明效果: https://youtu.be/ESSsY2m7vTY?t=28
当我的看起来像这样时: https://youtu.be/Jnm9jN4-wWY
这是我的小部件:
FlexibleSpaceBar(
collapseMode: CollapseMode.parallax,
background: Hero(
tag: widget.newRent == false
? 'rent-image${Provider.of<MyRents>(context).currenRentIndex}'
: 'new-rent-image',
child: _imageEdited == false
? myRent['images'].isNotEmpty
? CachedNetworkImage(
imageUrl: myRent['images'][0],
fit: BoxFit.cover,
placeholder: (context, url) =>
Center(child: CircularProgressIndicator()),
errorWidget: (context, url, error) =>
errorImage(context),
)
: Provider.of<MyRents>(context, listen: false)
.newGalleryImages
.isNotEmpty
? Image.file(
Provider.of<MyRents>(context, listen: false)
.newGalleryImages[0],
fit: BoxFit.cover)
: Container(
padding: const EdgeInsets.all(20.0),
child: Image(
image:
AssetImage('assets/images/icon.jpg'),
),
)
: Image.file(myRent['images'][0], fit: BoxFit.cover),
),
),
删除所有检查后,这是一个基本的 FlexibleSpaceBar 和 Hero 转换,没什么特别的
【问题讨论】:
-
你可以添加一些 UI sn-ps 比如你想要什么??
-
已编辑问题
-
我知道你在说什么。只是当您向上滑动时,标题的背景变得越来越明显(在图片顶部)。对吧?
-
不,您向下滑动(普通滚动没有拉伸或类似的)。如果没有 SliverAppBar,图像会获得不透明效果。在这里您看不到它,因为它将标题移动到 AppBar 但它发生在我的案例中:api.flutter.dev/flutter/material/FlexibleSpaceBar-class.html
-
我添加了视频链接。你可以看到我不想拥有的不透明度