【发布时间】:2018-08-21 22:18:05
【问题描述】:
通过 .documents[x] 获取文档,其中 x 是从零开始的文档编号,在此示例中有效。如何通过键值获取文档? 例如,第 3 个文档的键为“qwwe”
我怎样才能得到这份文件?
Snapshot.data.document["qwwe"]?
这是与代码问题代码一起工作的代码 // out.
//======= this works
// body: new ListOfNACS01(),
body: new StreamBuilder(
// stream: Firestore.instance.collection('COMPLEX_NONACS').document('A01B01C01D02').snapshots(),
stream: Firestore.instance.collection('COMPLEX_NONACS').snapshots(),
builder: (context, snapshot){
if (!snapshot.hasData) return const Text("--- loading ---");
// return new ListView.builder(
// itemCount: snapshot.data.document.length,
// );
return Column(
children: <Widget>[
Text(snapshot.data.documents[0].documentID),
Text(snapshot.data.documents[0]["DE02PRIMARY"]["INDICATION"]),
//-------- this does not work ------------
// how to display a document by DocumentID?
// -- The below line gives error of...
// error: Too many positional arguments: 1 expected, but 2 found.
// (extra_positional_arguments_could_be_named at [scaiqit55]
// lib/main.dart:48).
Text(snapshot.data.document['A01B01C01D01']),
Text(snapshot.data.documents[0]["DE02PRIMARY"]["INDICATION"]),
],
);
},
),
);
}
}
【问题讨论】:
-
经过一番研究...看来我应该使用此评论...github.com/flutter/flutter/issues/14919
标签: flutter google-cloud-firestore