快照适用于文档[索引],但不适用于文档(ID)

问题描述 投票:0回答:1

我想基于文档ID而不是文档索引访问流构建器。请帮助。

        StreamBuilder(
            stream: Firestore.instance.collection('users').snapshots(),
            builder: (context, snapshot){

              if(!snapshot.hasData) return Text('Loading data.....');
              return
                  Center(child: Text(snapshot.data.documents[0]["Name"]),);
flutter snapshot stream-builder
1个回答
0
投票

您可以获得这样的特定文档,

Firestore.instance
        .collection('users')
        .document('Name')//your document name
        .get()
        .then((DocumentSnapshot ds) {
      // use ds as a snapshot
    });
© www.soinside.com 2019 - 2024. All rights reserved.