i want to add user data to the firebase using firestore ,i am watching toutial form udemy but due to firestore update i face this error(The method 'document' isn't defined for the type 'CollectionReference'. Try correcting the name to the name of an existing method, or defining a method named 'document'.)
await FirebaseFirestore.instance
.collection('users')
.document(userCredential.user?.uid)//The method 'document' isn't defined for the type 'CollectionReference'.
Try correcting the name to the name of an existing method, or defining a method named 'document'.
.setData({
'username': username,
'email': email,
});
document
is changed to doc
and setDocument
to set
Here is correct code:
await FirebaseFirestore.instance
.collection('users')
.doc(userCredential.user?.uid)
.set({
'username': username,
'email': email,
});