我的flutter应用程序有问题,问题在于firebase的存储。我有一个名为avatar(String)
的字段集合。它的价值来自图像链接,因此首先我将图像上传到Firebase存储,然后更改了允许读取的规则。因此,当我刷新代码时会收到此错误。
═══════ Exception caught by image resource service ════════════════════════════════════════════════
抛出以下ArgumentError来解析图像
codec:
Invalid argument(s): Unsupported scheme 'gs' in URI gs://pfe-2020-51d9c.appspot.com/Asperge/asperges%20(1).jpg
引发异常时,这是堆栈:
#0 _HttpClient._openUrl (dart:_http/http_impl.dart:2278:9)
#1 _HttpClient.getUrl (dart:_http/http_impl.dart:2197:48)
#2 NetworkImage._loadAsync (package:flutter/src/painting/_network_image_io.dart:84:59)
#3 NetworkImage.load (package:flutter/src/painting/_network_image_io.dart:47:14)
#4 ImageProvider.resolve.<anonymous closure>.<anonymous closure>.<anonymous closure> (package:flutter/src/painting/image_provider.dart:327:17)
...图片提供者:NetworkImage(“ gs://pfe-2020-51d9c.appspot.com/Asperge/asperges(1).jpg”,比例尺:1.0)图片键:NetworkImage(“ gs://pfe-2020-51d9c.appspot.com/Asperge/asperges(1).jpg”,比例尺:1.0)══════════════════════════════════════════════════ ══════════════════════════════════════════════════
这是我的飞镖代码
================================================ ================================================== =
ClipRRect(
child: Image.network(snapshot.data[index].data['avatar'],
height: 100,
width: 170,
fit: BoxFit.fill,
),
borderRadius: BorderRadius.circular(20),
),
Flutter不知道如何处理Cloud Storage本机用来描述上传文件位置的URL。该“ gs://”表示Cloud Storage使用的自定义方案。您需要做的是提供Flutter可以理解的URL。
您可以通过using getDownloadUrl()从上载的文件中获取HTTPS下载URL。那是您应该提供给Flutter的URL,以下载并显示图像。