I want to get data from firestore, but I can't seem to do it properly and it always returns null. Here's what I tried:
Map<String, dynamic>? userMap2;
void getCurrentUser() async {
FirebaseFirestore _firestore = FirebaseFirestore.instance;
final User? user = _auth.currentUser;
final uuid = user!.uid;
setState(() {
isLoading = true;
});
await _firestore
.collection('users')
.where("uid", isEqualTo: uuid)
.get()
.then((value) {
setState(() {
userMap2 = value.docs[0].data();
isLoading = false;
});
print(userMap2);
});
}
and when I try to use that data, I try to use it like this: userMap2!['firstName']