I am using Firebase database and I have app like "google keep" when user put data I will save data in sqfLite then if the user is Connected to the Network I will save data in Firebase with Milliseconds and save same Milliseconds on device then next time when user add data I see if Milliseconds on Firebase = Milliseconds on device if that true I add change to Firebase if not I get data from Firebase. I think this way have some error. is there better way to do that ?
Asked
Active
Viewed 1,820 times
0
-
No, this will work fine. Also see https://stackoverflow.com/questions/50471309/how-to-listen-for-document-changes-in-cloud-firestore-using-flutter – Milvintsiss Apr 16 '20 at 01:54
1 Answers
0
Firestore database is meant to be in sync all across the devices for a particular user. You can either do the comparison manually or simply put a listener. A listener will automatically push the data whenever user logs in from a new device keeping the data consistent all across.
This is a quick video demonstrating how to achieve 'automatic' sync all across the devices. All you need to add is the user/account filter.

Sukhi
- 13,261
- 7
- 36
- 53