在 Flutter 中重新加载图像帧

Mal*_*olm 2 image dart flutter

我正在我的 flutter/dart 应用程序中从 TCP 服务器接收图像。每次我将图像加载到内存中时,我都会刷新显示,但刷新根本不平滑。有一个间隙,图像消失然后重新出现。

我正在使用构造函数Image.memory来构建图像。到目前为止我已经尝试过:

  • 将新图像加载为 Uint8List 并使用 setState() 重新加载页面并重建 Image.memory
  • 加载 Image.memory,将其添加到 StreamController 中并使用 StreamBuilder 构建图像视图。

在每种情况下,首先旧图像消失,然后第二个图像出现。是由于 Image.network 的实现还是我的代码中有其他错误?我怎样才能避免图像的“颤动”?

Mal*_*olm 5

按照古老的传统,在花费 2 小时寻找解决方案并最终在 StackOverflow 上询问后立即找到解决方案,只需要做Image.memory(last_loaded_img, gaplessPlayback: true)