Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

storing user data in firebase

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,
            });

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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,
                });
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading