2

I sign in my user through google, after successfully login. I wants to create document for each user inside user_details collection and the document name should be google id. But its auto generating document name.

Is there any way to create custom document in Firestore?

Thanks in Advance

// Store data in Firestore storeData(User user) async { DocumentReference documentRef = Firestore.instance.collection("user_details").document(user.id); Firestore.instance.runTransaction((transaction) async { await transaction.set(documentRef, user.toJson()); print("instance created"); _login.add(Result(Status.SUCCESS, "Login successful.", user)); }); } 
3
  • Try this await documentRef.setData(user.toJson()); Commented Jul 10, 2019 at 7:29
  • @HarjotSingh Yes its working Commented Jul 10, 2019 at 9:09
  • Then I am adding as an answer please accept. Commented Jul 10, 2019 at 9:13

1 Answer 1

1

Try this await documentRef.setData(user.toJson());

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.