Advertisement
anik11556

saveCredential

Nov 7th, 2023
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. var collectionReference = FirebaseFirestore.instance.collection('users');
  2. var query = collectionReference.where('id', isEqualTo: firebaseAuth.currentUser!.uid );
  3. var querySnapshot = await query.get();
  4.  
  5. if (querySnapshot.docs.isNotEmpty) {
  6. // Access the first document (you may need to loop through if you expect multiple matches)
  7. var doc = querySnapshot.docs[0].data();
  8.  
  9. String bio = doc['bio'];
  10. String country = doc['country'];
  11. String email = doc['email'];
  12. String gender = doc['gender'];
  13. String id = doc['id'];
  14. bool isOnline = doc['isOnline'];
  15. Timestamp lastSeen = doc['lastSeen'];
  16. String photoUrl = doc['photoUrl'];
  17. String userName = doc['username'];
  18. Timestamp time = doc['time'];
  19.  
  20.  
  21. User curUser = new User.Complete(userName,email,country,bio,gender,photoUrl,id,lastSeen,isOnline,time);
  22.  
  23. print(curUser.email);
  24. } else {
  25. print('No matching documents found.');
  26. }
  27.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement