Mobile — Flutter
Choose Your Synchronization Strategy
Three ways data can move between the device and the server — pick the one that matches how offline-tolerant a feature needs to be.
Data
Choose your synchronization strategy
A — Direct RemoteSaves data to the server first, then updates the copy on the device once that succeeds. The default option — good for most apps.
B — Offline-OnlyOnly saves data on the device — nothing is sent to a server. Use this if the app doesn't need to sync at all.
C — Outbox SyncSaves data on the device right away, so the screen updates instantly, then sends it to the server in the background once the device is back online.
sync architecture
UI
│
▼
Local Drift Database
│
▼
syncQueueEntries
│
▼
Background Worker
│
▼
Remote Backend
│
└── REST / Firebase
How to switch strategies: there's no setting to flip — you edit the code directly. Open updateCounter() in counter_repository_impl.dart: Strategy A is the active code, and Strategy C sits right below it, commented out. To switch, comment out A and uncomment C. For Strategy B, just skip the server call and save to _localDatasource only.