1

I have a Flutter mobile application, where several people can read the same firestore document in real time using StreamBuilder (obviously one person can leave the room). At the same time, to switch from one screen to another, I have a 30 second counter (I use the package https://pub.dev/packages/flutter_countdown_timer). When the counter reaches 0, I update a field in the firestore document (increment the field by 1) and I go to another screen.

What is the best solution to guarantee that the document update will be done by a single user (single instance of the app) and to prevent a false operation (do two increments for example)

Idriss
  • 354
  • 3
  • 10
  • 1
    This sounds pretty close to what I showed in [How do I implement a write rate limit in Cloud Firestore security rules?](https://stackoverflow.com/questions/56487578/how-do-i-implement-a-write-rate-limit-in-cloud-firestore-security-rules) Using the approach outlined there, you can ensure that the document only can be updated once per 30s (or whatever interval you choose). – Frank van Puffelen Jan 04 '23 at 14:51

0 Answers0