在Flutter中从Firebase存储获取图像时出现错误?

huangapple go评论97阅读模式
英文:

Error while fetching image from firebase storage in flutter?

问题

在从Firebase存储获取图像时,出现错误。我已经编写了以下代码:

  1. body: FirebaseAnimatedList(
  2. query: dbRef.child('Post List'),
  3. itemBuilder: (context, snapshot, animation, index) {
  4. return Container(
  5. child: FadeInImage.assetNetwork(
  6. placeholder: 'assets/icon.png',
  7. image: snapshot.value['pImage'],
  8. ),
  9. );
  10. },
  11. )

它抛出以下错误:

  1. assert(() {
  2. if (widget.errorBuilder == null) {
  3. // ignore: only_throw_errors, since we're just proxying the error.
  4. throw error; // Ensures the error message is printed to the console.
  5. }
  6. return true;
  7. }

调试控制台输出的图像如下:
在Flutter中从Firebase存储获取图像时出现错误?
在Flutter中从Firebase存储获取图像时出现错误?

英文:

I am creating blog app and during fetching image from firebase storage it throws error.
I have written the following code:

  1. body: FirebaseAnimatedList(
  2. query: dbRef.child('Post List'),
  3. itemBuilder: (context, snapshot, animation, index) {
  4. return Container(
  5. child: FadeInImage.assetNetwork(
  6. placeholder: 'assets/icon.png',
  7. image: "snapshot.value['pImage']"),
  8. );
  9. },
  10. )

It throws following error:

  1. assert(() {
  2. if (widget.errorBuilder == null) {
  3. // ignore: only_throw_errors, since we're just proxying the error.
  4. throw error; // Ensures the error message is printed to the console.
  5. }
  6. return true;

Images of debug console output is as following:
在Flutter中从Firebase存储获取图像时出现错误?
在Flutter中从Firebase存储获取图像时出现错误?

答案1

得分: 1

image: "snapshot.value['pImage']"),
这是错误的原因。从这里移除""。或者:

image: "${snapshot.value['pImage']}"),

英文:
  1. image: "snapshot.value['pImage']"),

I think that is the cause of error. Remove "" from here. Or:

  1. image: "${snapshot.value['pImage']}"),

huangapple
  • 本文由 发表于 2023年2月8日 12:34:31
  • 转载请务必保留本文链接:https://go.coder-hub.com/75381414.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定