Optimistic writes look easy until the app dies mid-request. I built an offline-first sync queue for Flutter with no sync package behind it, and these are the four bugs that cost me the most time β plus how I fixed each one.
The queue is a log of intent, not a list of API calls
Optimistic writes look easy: update the UI, fire the request, show an error if it
fails. The trouble starts when the app dies, the network flaps, or two devices
edit the same row.
I built SyncSpool Kit around one idea: the UI applies a change to local state and
appends an intent to a queue. The queue owns the network from then on.β¦