These are the upload details to a Firestore document.
'uid': this._userId,
'Email': this._email,
'Fullname': this._fullname,
'Location': this._location,
'ImageUrl': this._imageurl = await uploadImage(),
Using the code below — if I am correct — I'm trying to access the details of current user using the uid
code present in the document.
final user = FirebaseAuth.instance.currentUser();
getData() async {
return await Firestore.instance
.collection('userdetails')
.where('uid', isEqualTo: user)
.getDocuments();
}
Now, as the method returns the document with the user details of the current user, how can I access each of the values to display on screen.Name
and Image URL?
I would not expect that code to work, since user
is a FirebaseUser object, and not a UID string. You probably want this instead to use the uid of the current user to filter the results:
Firestore.instance
.collection('userdetails')
.where('uid', isEqualTo: user.uid)
.getDocuments();
Here's how to access those fields:
Firestore.instance.collection('userdetails').document(user.uid).get().then((doc) {
_fullname = doc.data['Fullname'];
_imageUrl = doc.data['ImageUrl'];
}
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.