halahmadi
halahmadi

Reputation: 125

Flutter Firestore: How to check if all document writes completed successfully

When the device is offline, the app stores any Firestore changes locally and update them when the internet connection is back. Is there a way to check in the app if the local changes finished uploading Firestore?

Upvotes: 1

Views: 1034

Answers (1)

Frank van Puffelen
Frank van Puffelen

Reputation: 599041

There's no API to get a list of the pending writes, nor is there a flag that signals whether there are pending writes. But there are a few things you can do:

  1. For a specific write, you can attach a completion listener to detect when it has completed. When the Future that the write resolves, the write has been committed on the server.

  2. When you're getting a DocumentSnapshot, you can check the hasPendingWrites property in its metadata to see whether the snapshot has pending changes.

Upvotes: 2

Related Questions