android - 加载 flutter 时去除图像中的白色闪烁

我正在构建一个在 GridView 中显示数百张图像的应用程序。在网格图 block 中,我展示了低质量的图像。当我们按下图像时,我会显示完整质量的图像,同时,我会显示低质量图像作为占位符。我正在使用 CachedNetworkImage 包。这里的问题是当加载全质量图像时会出现一些白色闪烁,如 here 所示。 .我想删除那个 flickr。有什么方法可以删除那个吗?

这是我的代码。

 Widget cachedImage(imageUrl) {
    return CachedNetworkImage(
      imageUrl: imageUrl,
      imageBuilder: (context, imageProvider) => Container(
            decoration: BoxDecoration(
              color: Theme.of(context).shadowColor,
                borderRadius: BorderRadius.circular(10),
                boxShadow: <BoxShadow>[
                  BoxShadow(
                      color: Theme.of(context).shadowColor,
                      blurRadius: 2,
                      offset: Offset(2, 2))
                ],
                image: DecorationImage(
                    image: imageProvider,
                    fit: BoxFit.cover)),
          ),
      placeholder: (context, url) => LoadingWidget1(),
      errorWidget: (context, url, error) => Center(child: Icon(Icons.error)),
    );
  }

//code for thumbnail image
Hero(
    tag: 'category$index',
    child: cachedImage(d['thumbnail url'])
),

//Code for FullQuality Preview

....
child: CachedNetworkImage(
                placeholderFadeInDuration: Duration(microseconds: 0),
                useOldImageOnUrlChange: true,
                imageUrl: imageUrl,
                imageBuilder: (context, imageProvider) => Container(
                  decoration: BoxDecoration(
                      image: DecorationImage(
                          image: imageProvider, fit: BoxFit.cover)),
                ),

                placeholder: (context, url) => Stack(
                  children: [

                    CachedNetworkImage(
                      imageUrl: thumbUrl,
                      imageBuilder: (context, imageProvider) => Container(
                      decoration: BoxDecoration(
                          image: DecorationImage(
                              image: imageProvider, fit: BoxFit.cover)),

                    ),

                  ),

最佳答案

CachedNetworkImage 中有 2 个淡入淡出持续时间默认值为非 null(顺便说一下,placeholderFadeInDuration 为 null),您可以尝试将 fadeOutDurationfadeInDuration 归零:

https://stackoverflow.com/questions/69930018/

相关文章:

python - 如何自定义条形注释以不显示选定值

computer-vision - 不同相机 View 之间的映射

amazon-web-services - AWS CodePipeline 角色无权在阶段的 "a

python - TensorFlow 安装错误,未启用 Windows LongPath 支持

unit-testing - 使用 Jest 测试 Vue3 组件时如何模拟计算属性

python - IPywidgets 观察包裹在一个类中时不起作用

python - 一段时间后 Discord api websocket 网关连接断开

c# - 当我更改继承类中同名方法的代码时,我不需要使用属性覆盖和虚拟。这是为什么?

kubernetes - 如何在我的 Kubernetes 容器中安装 tar 二进制文件以使 ku

c# - 由于 XmlSerialization (sgen.exe) 无法在 Visual Stu