【问题标题】:How to cache image from was s3 url in flutter如何在颤动中缓存来自s3 url的图像
【发布时间】:2021-03-25 06:54:01
【问题描述】:

我有一个 AWS S3 图像 url。我想在我的 Flutter 应用程序中下载图像后缓存它,我该如何实现这一点

【问题讨论】:

    标签: image flutter amazon-s3


    【解决方案1】:

    您可以使用CachedNetworkImage

    CachedNetworkImage(
      imageUrl: 'https://your.url',
      progressIndicatorBuilder: (context, url, progress) => Center(child: CircularProgressIndicator()),
      height: MediaQuery.of(context).size.height * 0.1,
      placeholder: (context, url) => Image.asset('images/NoImage.png'),
    ),
    

    或者,如果您想在设备上存储图像,则可以使用 sqflite 并将图像作为 Uint8List 或字符串字节存储到数据库。图像小部件具有 Image.memory 方法,用于从存储在数据库中的 Uint8List 获取图像

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-11-04
      • 1970-01-01
      • 2021-06-11
      • 1970-01-01
      • 2021-06-03
      • 2021-12-17
      • 2018-12-19
      • 2021-04-16
      相关资源
      最近更新 更多