Flutter show image with network url 直接从 Firestore 非常慢

Flutter show image with network url directly form Firestore is very slow

我将 Firestore 图像 url 存储在我的数据库中,并直接从 flutter 应用程序中获取。即使与 DO 每月 6 美元的服务器上的图像托管相比,它也非常慢。我花了将近一分钟来显示图像。有什么办法可以提高速度吗?

https://firebasestorage.googleapis.com/v0/b/myproject.appspot.com/o/images%2Falbums%2Fchin%20thae%20lae%20pyan.jpg?alt=media&token=9966803a-d4a7-4686-a0c2-8f5367bc89f6

Container(
                  decoration: BoxDecoration(
                    image: DecorationImage(
                      image: NetworkImage(album.albumCover),
                      fit: BoxFit.cover,
                    ),
                  ),
                  child: Align(
                    alignment: Alignment.bottomRight,
                    child: Container(
                      margin: const EdgeInsets.all(5),
                      //padding: const EdgeInsets.all(5),
                      decoration: BoxDecoration(
                          color: Theme.of(context).primaryColor,
                          borderRadius: BorderRadius.circular(100)),
                      child: const Icon(
                        Icons.play_arrow,
                        color: Colors.white,
                      ),
                    ),
                  ),
                )

您好,您需要可以使用 CachedNetworkImage 而不是 NetworkImage 参考下面

CachedNetworkImage

CachedNetworkImage(
      imageUrl: "your_image_url",
      imageBuilder: (context, imageProvider) => Container(
        decoration: BoxDecoration(
          image: DecorationImage(
              image: imageProvider,
              fit: BoxFit.cover,
          ),
        ),
      ),
      placeholder: (context, url) => CircularProgressIndicator(),
      errorWidget: (context, url, error) => Icon(Icons.error),
    ),

如果您有任何疑问,请告诉我