Building an Offline-First Mobile App with Flutter and Sembast
A practical guide to syncing field attendance data automatically using local caching and background jobs in Flutter.

The Problem
For the Hamada Operations Platform, drivers often operate in remote areas with poor or zero internet connectivity. However, they still need to scan QR codes and log their GPS locations for attendance and delivery proofs.
The Offline-First Strategy
Instead of relying solely on network requests, we implemented an offline-first architecture.
- Local Storage: We used
Sembast, a NoSQL persistent store for Dart, to save all attendance logs locally on the device first. - State Management: The UI reads directly from the local database, ensuring zero-latency interactions for the drivers.
- Background Synchronization: We built a sync manager that listens for connectivity changes. Once the device is back online, it batches the unsynced records and pushes them to our Laravel backend securely using Sanctum tokens.
Handling Conflicts
Since drivers could theoretically use multiple devices, we implemented a server-side timestamp conflict resolution. The server always holds the source of truth, and devices sync their local cache based on the latest server timestamp.
Result
Data loss incidents dropped to 0%, and driver satisfaction increased significantly since they no longer had to wait for loading spinners in the middle of a delivery route.
Related Articles

Implementing Clean Architecture in NestJS for Enterprise Platforms
How we structured our enterprise digital platform using NestJS, Clean Architecture, and Redis to achieve high scalability and maintainability.

Why Go Was the Perfect Choice for Our SLA Incident Manager
Exploring the performance and concurrency benefits of Go (Golang) when building an enterprise incident management system.