anik11556

specificFiledValue_query

Nov 7th, 2023
17
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 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 document = querySnapshot.docs[0].data();
  8.  
  9. // Access the specific field in the document
  10. var specificElement = document['username'];
  11.  
  12. // Now you can work with the specific element
  13. print('Found specific element: $specificElement');
  14. } else {
  15. print('No matching documents found.');
  16. }
  17.  
  18.  
Add Comment
Please, Sign In to add comment