1 | initial version |
To retrieve information specifically for the present user using Flutter and Firestore, you can follow these steps:
import 'package:firebase_auth/firebase_auth.dart';
FirebaseUser user = await FirebaseAuth.instance.currentUser();
String uid = user.uid;
import 'package:cloud_firestore/cloud_firestore.dart';
QuerySnapshot snapshot = await Firestore.instance.collection('users').where('uid', isEqualTo: uid).getDocuments();
data
property.Map<String, dynamic> userData = snapshot.documents[0].data;
Note: You need to make sure that you have set up the Firestore rules to only allow the current user to access their own data.