[英]Is there any difference between using async* and yield* or not on returning FirebaseFirestore QuerySnapshot
第一种情况和第二种情况有什么区别吗?
1.
Stream<QuerySnapshot> streamUsersOne() async* {
yield* FirebaseFirestore.instance.collection('users').snapshots();
}
2.
Stream<QuerySnapshot> streamUsersTwo() {
return FirebaseFirestore.instance.collection('users').snapshots();
}
第一个(async* 和 yield)在您创建自己的 Stream 时使用,这里不需要使用它,因为 snapshots 方法已经返回 Stream 类型。 您可以观看此 剪辑以了解有关如何创建流的更多信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.