Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/http/4.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 是否有方法检索Firestore集合中的文档并将其存储为列表<;用户定义的类>;?_Firebase_Flutter_Dart_Google Cloud Firestore - Fatal编程技术网

Firebase 是否有方法检索Firestore集合中的文档并将其存储为列表<;用户定义的类>;?

Firebase 是否有方法检索Firestore集合中的文档并将其存储为列表<;用户定义的类>;?,firebase,flutter,dart,google-cloud-firestore,Firebase,Flutter,Dart,Google Cloud Firestore,标题不言自明。一些示例代码将不胜感激 如果可能,是否有方法提取与文档中特定字段的值相对应的集合中的所有文档(即筛选实现)?是,这是可能的。您可以使用StreamBuilder。例如: StreamBuilder( stream: Firestore.instance .collection("yourCollection")

标题不言自明。一些示例代码将不胜感激


如果可能,是否有方法提取与文档中特定字段的值相对应的集合中的所有文档(即筛选实现)?

是,这是可能的。您可以使用
StreamBuilder
。例如:

                StreamBuilder(
                  stream: Firestore.instance
                           .collection("yourCollection")
                           .where("query", isEqualTo: "something"),
                           .snapshots();
                  builder: (context, snapshot) {
                    if (snapshot.hasError) {
                      return Center(
                        child: Text("Error fetching posts ${snapshot.error}"),
                      );
                    }
                    if (snapshot.hasData) {
                      List<UserDefinedModel> list = snapshot.data.documents;

                      // other code...
                      // return Widget
                    }
                  }
               );
StreamBuilder(
流:Firestore.instance
.收藏(“你的收藏”)
。其中(“查询”,isEqualTo:“某物”),
.快照();
生成器:(上下文,快照){
if(snapshot.hasError){
返回中心(
子项:Text(“获取帖子时出错${snapshot.Error}”),
);
}
if(snapshot.hasData){
列表=snapshot.data.documents;
//其他代码。。。
//返回小部件
}
}
);

是的,这是可能的。您可以使用
StreamBuilder
。例如:

                StreamBuilder(
                  stream: Firestore.instance
                           .collection("yourCollection")
                           .where("query", isEqualTo: "something"),
                           .snapshots();
                  builder: (context, snapshot) {
                    if (snapshot.hasError) {
                      return Center(
                        child: Text("Error fetching posts ${snapshot.error}"),
                      );
                    }
                    if (snapshot.hasData) {
                      List<UserDefinedModel> list = snapshot.data.documents;

                      // other code...
                      // return Widget
                    }
                  }
               );
StreamBuilder(
流:Firestore.instance
.收藏(“你的收藏”)
。其中(“查询”,isEqualTo:“某物”),
.快照();
生成器:(上下文,快照){
if(snapshot.hasError){
返回中心(
子项:Text(“获取帖子时出错${snapshot.Error}”),
);
}
if(snapshot.hasData){
列表=snapshot.data.documents;
//其他代码。。。
//返回小部件
}
}
);