Flutter Firestore add new document with Custom ID

前端 未结 2 927
太阳男子
太阳男子 2021-02-12 20:40

How to add new document with custom id using Dart and Flutter?

PS: I can add new document to collection but its id sets randomly, using this code

2条回答
  •  花落未央
    2021-02-12 21:12

    String uniqueCode = //Your Unique Code
    DocumentReference reference = Firestore.instance.document("test/" + uniqueCode );
    
    //Setting Data
    Map yourData;
    reference.setData(yourData);
    

提交回复
热议问题