In the last update of cloud_firestore, I get an error when I run the app with the old code. How can I convert a Stream<QuerySnapshot<Map<String, dynamic> >> 到列表? Flutter In the last update of cloud_firestore, I get an error when I run the app with the old code. How can I convert a Stream<QuerySnapshot<Map<String, dynamic>,firebase,flutter,dart,google-cloud-firestore"/>
In the last update of cloud_firestore, I get an error when I run the app with the old code. How can I convert a Stream<QuerySnapshot<Map<String, dynamic>,firebase,flutter,dart,google-cloud-firestore"/>
首页 > 解决方案 > 如何转换流>> 到列表? Flutter In the last update of cloud_firestore, I get an error when I run the app with the old code. How can I convert a Stream<QuerySnapshot<Map<String, dynamic> firebase - 如何转换流>> 到列表? Flutter In the last update of cloud_firestore, I get an error when I run the app with the old code. How can I convert a Stream<QuerySnapshot<Map<String, dynamic> 问题描述 In the last update of cloud_firestore, I get an error when I run the app with the old code. How can I convert a Stream<QuerySnapshot<Map<String, dynamic>>> to a List? I have this code and I get null values: Stream<List<Model>> getReviews(String id) { try { return _collectionReference.doc(id).collection('reviews').orderBy('date', descending: true).snapshots().map((reviews) => reviews.docs.map((review) => Model.fromJson(review.data()))); } catch (error) { return error.message; } } Turns out I was attempting to run reverse in a module that would cause circular import. The solution was to use reverse_lazy as suggested in the comments. 标签: firebaseflutterdartgoogle-cloud-firestore 解决方案 如果您只想在此处返回类似内容之前List<Model>使用get调用并等待结果:List<Model> Future<List<Model>> getReviews(String id) { try { QuerySnapshot querySnapshot=await _collectionReference.doc(id).collection('reviews').orderBy('date', descending: true).get(); List<Model> result; querySnapshot.docs.forEach((doc) { print(doc["first_name"]); result.add(Model.fromJson(review.data())); }); return result; } catch (error) { return error.message; } 确保以getReviews异步方式调用。 推荐阅读 python - 快速排序 Python 递归 - 递归函数是如何工作的python - 如何将对象插入到MongoDB中的对象中java - Java“消息”:“令牌上的语法错误\”;\”,{此令牌后预期”database - 如何在 Oracle 数据库 11g 中创建本地模式?sql - 可序列化隔离级别的意外行为python - 如何使用pyspark从文件中查找分隔符javascript - Fusion Charts Zoomline React 错误:ChunkLoadError:加载块 6 失败command-line - 如何在命令行上处理 .fsproj 文件?python - 在 Flask 中将蓝图注册到应用程序中是什么意思?javascript - 如何添加属性或更改按钮的样式 onPress react native - native base
In the last update of cloud_firestore, I get an error when I run the app with the old code. How can I convert a Stream<QuerySnapshot<Map<String, dynamic>
In the last update of cloud_firestore, I get an error when I run the app with the old code. How can I convert a Stream<QuerySnapshot<Map<String, dynamic>>> to a List?
I have this code and I get null values:
Stream<List<Model>> getReviews(String id) { try { return _collectionReference.doc(id).collection('reviews').orderBy('date', descending: true).snapshots().map((reviews) => reviews.docs.map((review) => Model.fromJson(review.data()))); } catch (error) { return error.message; }
}
Turns out I was attempting to run reverse in a module that would cause circular import. The solution was to use reverse_lazy as suggested in the comments.
reverse
reverse_lazy
标签: firebaseflutterdartgoogle-cloud-firestore
如果您只想在此处返回类似内容之前List<Model>使用get调用并等待结果:List<Model>
List<Model>
get
Future<List<Model>> getReviews(String id) { try { QuerySnapshot querySnapshot=await _collectionReference.doc(id).collection('reviews').orderBy('date', descending: true).get(); List<Model> result; querySnapshot.docs.forEach((doc) { print(doc["first_name"]); result.add(Model.fromJson(review.data())); }); return result; } catch (error) { return error.message; }
确保以getReviews异步方式调用。
getReviews