I am trying to send the data to firebase in my project which I was able to , yet I want the data to override the variable. The one I am using is adding at all the time
setState(() {
velocity = newVelocity;
if (velocity > highestVelocity) {
highestVelocity = velocity;
}
});
future= new Future.delayed(const Duration(seconds: 5));
_firestore.collection('collectionName').add({
'velocity' : velocity
});
}
I think there is update function to override the var. Can I someone help me with that?
Solution 1: Frank van Puffelen
To update an existing document, you must know the ID of that document. Once you do, you can update it with:
_firestore.collection('collectionName').doc("theIdOfYourDocument").set({
'velocity' : velocity
});
Also see: how can I set my document id as user uid in cloud fire store?