r/FlutterDev • • Jun 30 '26

Discussion Flutter + Supabase realtime: what broke in v1.0.9 when two people edited at once

Solo dev, Flutter household app, just shipped v1.0.9. Hit a realtime bug I want to talk about.

Setup: Supabase, postgres_changes broadcast, optimistic delete. Worked fine for me testing alone. Tried it on a second phone — same field, same time — last write won silently. No UI feedback. Person A made a change, person B's app happily overwrote it. Embarrassing.

What I did: added a row version column, push conflict events back to the client, app toasts "someone else just changed this." Not great UX but the silent corruption is gone.

Optimistic delete was the next headache. I tombstone the row locally until the server confirms — but RLS can deny a delete (e.g. someone in the household without permission) and I need to put the row back. Problem: the user's already navigated away. Now I keep a local "pending" table and reconcile on app foreground. Took me way too long to land on that.

Avatars: Supabase storage upload, fallback is a CustomPainter that draws initials with a hash-derived color. Avoided another asset lib for what's basically a circle with two letters.

Stack: Flutter stable, Supabase, RevenueCat, Firebase, AdMob with a no-ads-for-paying gate.

Curious how others handle realtime conflict resolution in Flutter — the row version + toast pattern works but I'm not sure it's the right model long-term.

3 Upvotes

6 comments sorted by

2

u/WheelAdditional6888 Jul 15 '26

This is exactly the kind of issue that never shows up when one person tests alone.

Silent overwrites are especially dangerous because users may not realize anything was lost. The versioning approach sounds solid, but making conflicts visible and recoverable may matter just as much as detecting them.

6

u/[deleted] Jun 30 '26

[removed] — view removed comment

1

u/mladenConcept Jul 01 '26

Thanks — that's the standard pattern confirmed.

One more thing, since you mentioned offline-reconciliation is "a little different" but didn't elaborate: what about read-your-own-writes offline? If I create a record on a plane and want to view it before going back online, the app needs to show it. If I just queue the insert and let sync sort it out, the read query either misses it or has to know about the queue separately. Do you keep a local "pending writes" cache the read path always joins, or something cleaner?