I am trying to get some fields in my firestore collection/document. I want to display them in some places in my code.
How can i get a particular field, like maybe phoneNumber from the user’s field in the document/collection.
THis is how the user’s data gets stored in the firebase.
//create UsersCollection data (First level verification) == Users Profile
Future createUserData(
String firstName,
String lastName,
String emailAddress,
String phoneNumber,
String gender
) async{
return getInstance.collection("users").doc(user!.email)
.collection("User Profile").doc(uid).set({
"firstName" : firstName,
"lastName" : lastName,
"emailAddress" : emailAddress,
"phoneNumber" : phoneNumber,
"gender" : gender
});
}
How can I get the phonenUmber maybe. Or even the firstName.
2
Answers
To get data from firebase you can try multiple ways
For fetching single item
You can also use a future builder like this
you can try this method and store the result in list