【发布时间】:2020-04-12 15:21:13
【问题描述】:
我正在使用 firestore 发布位置信息,并在单击按钮时将其数据保存到数据库中。 每个按钮单击它都会生成自动DocumnetID,并希望将此ID同时保存到数据库中。
代码:
await firestore.collection("Table_Name").document().setData({
"SpotLatLong":new GeoPoint(spotlat, spotlong) ,
"spotName": placeNameController.text,
"SpotImage":spotImage,
"UserID":uid,
"SpotActivity":spotActivity,
"SpotDocumentID": firestore.collection("Table_Name").document().documentID.toString()//this line generates Different documentID, which is wrong
}).then((onValue){
StyleWidget.showToast(msg: "Created spot to the table");
Navigator.pop(context);
isLoading = false;
});
【问题讨论】:
标签: database flutter dart google-cloud-firestore