简体   繁体   中英

iam using firebase firestore (flutter) dart

i want to get user type field from firestore to route the user to either (Store owner page ) or (Customer page )? 消防站

I want to get the value to decide which page the user should see

我试过这个功能,但没有用

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM