Offline-first mobile apps in Dart
Notes from building FINKI Life and Lexro around local SQLite storage before network sync.
Local state comes first
Mobile connections drop on buses, in lecture halls, and between cell towers. If your UI waits on a round-trip before rendering, the app feels broken.
With an offline-first architecture:
- Reads always hit SQLite on the device
- Writes append to a local mutation queue immediately
- Background sync reconciles with the server when connectivity returns
Comparing approaches
| Approach | Cold start | Offline writes | Complexity |
|---|---|---|---|
| Network-only | Slow | None | Low |
| Cache-aside | Fast | Read-only | Medium |
| Local-first | Instant | Full | Worth it |
Future<List<Note>> loadNotes(Database db) async {
final rows = await db.query('notes', orderBy: 'updated_at DESC');
return rows.map(Note.fromRow).toList();
}