[英]iam using firebase firestore (flutter) dart
you're trying to get the userType
field directly from the DocumentSnapshot
, which will return null
, you need to get data of field from the Map<String, dynamic>
which is returned from data()
, so you need to change:您正在尝试直接从
DocumentSnapshot
获取userType
字段,这将返回null
,您需要从Map<String, dynamic>
获取字段数据,这是从data()
返回的,因此您需要更改:
userType = documentSnapshot['userType'];
with this:有了这个:
userType = (documentSnapshot.data() as Map<String, dynamic>)['userType'];
this will save the value of userType field in the userType
variable.这会将userType字段的值保存在
userType
变量中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.