用颤振将数据发送到firebase
我正在尝试将数据发送到我的项目中的firebase,但我希望数据覆盖变量。我正在使用的那个一直在添加用颤振将数据发送到firebase,firebase,flutter,google-cloud-firestore,Firebase,Flutter,Google Cloud Firestore,我正在尝试将数据发送到我的项目中的firebase,但我希望数据覆盖变量。我正在使用的那个一直在添加 setState(() { velocity = newVelocity; if (velocity > highestVelocity) { highestVelocity = velocity; } }); future= new Future.delayed(const Duration(seconds: 5
setState(() {
velocity = newVelocity;
if (velocity > highestVelocity) {
highestVelocity = velocity;
}
});
future= new Future.delayed(const Duration(seconds: 5));
_firestore.collection('collectionName').add({
'velocity' : velocity
});
}
我认为有一个更新函数可以覆盖变量。有人可以帮我吗?要更新现有文档,您必须知道该文档的ID。完成后,您可以使用以下内容进行更新:
_firestore.collection('collectionName').doc("theIdOfYourDocument").set({
'velocity' : velocity
});
另请参见:要更新现有文档,您必须知道该文档的ID。完成后,您可以使用以下内容进行更新:
_firestore.collection('collectionName').doc("theIdOfYourDocument").set({
'velocity' : velocity
});
另请参见:非常感谢您的评论。我要工作了,但我必须将设置更改为setdatas。非常感谢您的评论。我得去工作,但我得把设置改成setdata