Flutter 中的 DocumentSnapshot 流

Stream for DocumentSnapshot in flutter

我想在 flutter 中创建一个 Stream<DocumentSnapshot> 以在 StreamBuilder 中使用。我知道我可以使用以下方法做到这一点: Firestore.instance.document("path").snapshots() 但我想要一个自定义 Stream 以便我可以控制我的文档被读取的速度。我想使用 Stream.periodic(Duration(seconds:5), ...).

请帮帮我。 提前致谢。

创建您自己的流并将文档添加到其中。

Timer.periodic(Duration(seconds: 3), (_) async{

     myStreamController.sink.add(
          await Firestore.instance.collection("Path").getDocuments()
     );
 });