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

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

Error while fetching image from firebase storage in flutter?

问题

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

body: FirebaseAnimatedList(
  query: dbRef.child('Post List'),
  itemBuilder: (context, snapshot, animation, index) {
    return Container(
      child: FadeInImage.assetNetwork(
        placeholder: 'assets/icon.png',
        image: snapshot.value['pImage'],
      ),
    );
  },
)

它抛出以下错误:

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

调试控制台输出的图像如下:
在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:

  body: FirebaseAnimatedList(
      query: dbRef.child('Post List'),
      itemBuilder: (context, snapshot, animation, index) {
        return Container(
          child: FadeInImage.assetNetwork(
              placeholder: 'assets/icon.png',
              image: "snapshot.value['pImage']"),
        );
      },
    )

It throws following error:

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

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

答案1

得分: 1

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

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

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

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

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:

确定