Issue
This is the code i have written but facing some error like "cant use String in getOptions()"
totalClasses = await FirebaseFirestore.instance
.collection('tutors')
.doc(uid)
.get("TotalClassesTook")
.then((value) {
return value.data();
});
How to retrieve the TotalClassesTook field value from this doc Error image
Solution
While using the FirebaseFirestore.instance
to get your data, the .get()
is for specifying the GetOptions
with feature like cache
.
But that is not what you require.
Use it like this,
totalClasses = await FirebaseFirestore.instance
.collection('tutors')
.doc(uid)
.get()
.then((value) {
return value.data()['TotalClassesTook']; // Access your after your get the data
});
Answered By - Nisanth Reddy
Answer Checked By - Cary Denson (JavaFixing Admin)