简体   繁体   English

Flutter Firestore Riverpod 获取数据问题

[英]Flutter Firestore Riverpod Getting Data Issue

I have a collection of normalads and I'm trying to read all document in this collection我有一个 normalads 集合,我正在尝试阅读这个集合中的所有文档

This code is working fine and printing all the documents in the collection & stopping for loop prints此代码工作正常并打印集合中的所有文档并停止循环打印

But when I try to add each document into an array it doesn't work and stopping for loop doesn't print但是当我尝试将每个文档添加到数组中时它不起作用并且停止 for 循环不会打印

Try this:尝试这个:

Future<List<NormalAdModel>> getNormalAdsFuture() async{
 final docs = await (firestore.collection("normalads").get()).docs;
 return docs.map((e) => NormalAdModel.fromMap(Map.from(e.data()!))).toList();
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM