Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Firebase 未来的建设者永远都在用颤振来获取图像_Firebase_Flutter_Firebase Storage - Fatal编程技术网

Firebase 未来的建设者永远都在用颤振来获取图像

Firebase 未来的建设者永远都在用颤振来获取图像,firebase,flutter,firebase-storage,Firebase,Flutter,Firebase Storage,这是_getImage方法,它从firebase存储中检索映像的下载链接,然后检索此下载字符串 Future<String> _getImage(String filePath) async { var _urlImage = await FirebaseStorage.instance .ref() .child(filePath) .getDownloadURL(); return _urlImage; } Fu

这是_getImage方法,它从firebase存储中检索映像的下载链接,然后检索此下载字符串

Future<String> _getImage(String filePath) async {
    var _urlImage = await FirebaseStorage.instance
        .ref()
        .child(filePath)
        .getDownloadURL();

    return _urlImage;
}

FutureBuilder
中的
future
参数应该是一个存储的变量,以便在
FutureBuilder
重建时,它不会每次都获得一个新的未来。 将
\u getImage
的结果存储在有状态小部件中(例如在
initState
中初始化),并将其传递给生成器。

FutureBuilder(
FutureBuilder<String>(
    future: _getImage(blogs[index].pic1),
    builder: (BuildContext context, AsyncSnapshot<Welcome> snapshot) {
      if (snapshot.hasData) {
        print("Success");
        return Text("Success!!!")
      } else if (!snapshot.hasData) {
         return Container(
            child: CircularProgressIndicator(),
          );
      } else if (snapshot.error) {
        print("error");
      } else {
        return Container(
            child: CircularProgressIndicator(),
          );
      }
    });
未来:_getImage(blogs[index].pic1), 生成器:(BuildContext上下文,异步快照){ if(snapshot.hasData){ 打印(“成功”); 返回文本(“成功!!!”) }如果(!snapshot.hasData){ 返回容器( 子对象:CircularProgressIndicator(), ); }else if(snapshot.error){ 打印(“错误”); }否则{ 返回容器( 子对象:CircularProgressIndicator(), ); } });

使用此方法dude

但是,我必须以listview格式显示图像。所以,它不是固定的
I/zygote64(20385): Background concurrent copying GC freed 546604(21MB) AllocSpace objects, 134(2MB) LOS objects, 24% free, 74MB/98MB, paused 70us total 509.383ms
FutureBuilder<String>(
    future: _getImage(blogs[index].pic1),
    builder: (BuildContext context, AsyncSnapshot<Welcome> snapshot) {
      if (snapshot.hasData) {
        print("Success");
        return Text("Success!!!")
      } else if (!snapshot.hasData) {
         return Container(
            child: CircularProgressIndicator(),
          );
      } else if (snapshot.error) {
        print("error");
      } else {
        return Container(
            child: CircularProgressIndicator(),
          );
      }
    });