Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
不能';无法在新的Flatter firebasefirestore中完成查询_Firebase_Flutter_Google Cloud Firestore - Fatal编程技术网

不能';无法在新的Flatter firebasefirestore中完成查询

不能';无法在新的Flatter firebasefirestore中完成查询,firebase,flutter,google-cloud-firestore,Firebase,Flutter,Google Cloud Firestore,我尝试运行此代码以获取FirebaseFirestore中对象中存储的值。但是没有得到任何输出 有人能帮我从Firestore数据库中获取特定字段吗 字符串val=FirebaseFirestore.instance .collection('用户') .doc(“$userId”) .get() .toString() 瓦尔回来了 闭包:()=>函数“数据”的映射: 我还尝试添加fieldpath(“displayName”和displayName)来获取。两者都显示错误。Firestore的

我尝试运行此代码以获取FirebaseFirestore中对象中存储的值。但是没有得到任何输出

有人能帮我从Firestore数据库中获取特定字段吗

字符串val=FirebaseFirestore.instance .collection('用户') .doc(“$userId”) .get() .toString()

瓦尔回来了

闭包:()=>函数“数据”的映射:


我还尝试添加fieldpath(“displayName”和displayName)来获取。两者都显示错误。

Firestore的所有查询本质上都是异步的

get()
函数的返回类型是未来的

要获得实际值,您应该等待异步调用完成,然后您就可以处理数据了

像这样的

FirebaseFirestore.instance
.collection('users')
.doc("$userId")
.get()
.then()((DocumentSnapshot data) {
    print(data);
    print(data['displayName');
});

谢谢!现在可以了!