我需要从firebase中获取特定元素。我不需要流生成器,只需要一个元素。谁能帮我 ?
我有这个:
final DocumentReference postRef = Firestore.instance.collection('Usuarios').document(email);
Firestore.instance.runTransaction((Transaction tx) async {
DocumentSnapshot postSnapshot = await tx.get(postRef);
if(postSnapshot.exists)
{
// do something
}
}
答案 0 :(得分:0)
也许这可以帮助您
QuerySnapshot querySnapshot = await Firestore.instance
.collection('Usuarios')
.where("email", isEqualTo: email)
.getDocuments();
var userList = querySnapshot.documents;
List<DocumentSnapshot> ds = userList;
ds.forEach((u) {
userName = u.data["name"];
});