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:
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.