genericUser
genericUser

Reputation: 7118

How to implement "message not delivered" on a Flutter Firestore chat application

TL;DR

I'm listening to Firestore changes using a snapshot. Snapshots documents are from cache. How can I indicate whether a DocumentSnapshot has delivered or not? Is there any flag which can indicate it?

More info

I'm developing a chat application, and I want to implement a "message not delivered" icon next to the message, same as WhatsApp does (on no network connection).

enter image description here

I'm using Firestore to collect my messages, and I'm listening to updates using a snapshot. Since I'm using Firestore snapshot, I'm getting my messages from the cache, while the cache itself updates on every change (which is pretty cool).

My issue is that I cannot indicate whether each message was delivered successfully or not.

A good use case is a user, with no network connection, that is sending a message, then closes the app, and re-opens it (without any network, cached only). I need to indicate to them that the last message has still not been delivered.

Upvotes: 1

Views: 554

Answers (1)

genericUser
genericUser

Reputation: 7118

The flag document.metadata.hasPendingWrites indicates whether the document was delivered or not.

Upvotes: 1

Related Questions