GDG Tech Wildcard Entry — App Development, Task 1.
A Flutter task manager that is fully usable with no internet and reconciles with a remote Postgres database when connectivity returns, without losing data or creating duplicate records.
The one idea this app is built on: the SQLite database on the phone is the source of truth. Supabase is a replica of it. No user action ever waits on the network — you write to SQLite, the screen updates, and a background worker catches up whenever it can.
| Requirement | Where |
|---|---|
| Create, edit, delete tasks; complete/pending; priorities; deadlines; categories; search & filter | features/tasks |
| Offline operation with persistent SQLite storage | core/database, features/tasks/data |
| Online/offline indicator; tasks survive restart | features/sync, SQLite |
| Queue offline changes, retry failures, prevent duplicates, resolve conflicts | features/sync/data/sync_service.dart |
| Immediate UI updates, state preserved across navigation, loading/empty/error states | features/tasks/presentation |
| No data loss if the app restarts mid-sync | outbox + single transaction |
| Multi-device support for one account (bonus) | auth + per-user RLS |
| Sync activity visible to the user (bonus) | sync banner + per-task badge |
Authentication is included (email/password and Google) because the brief requires syncing to a remote database and lists multi-device support for the same account. Without an identity, every install would write into one shared table. Signing in needs the internet once; after that the session is read from disk and the app opens straight into the task list with no signal.
Three layers, feature-first, dependencies pointing inward only.
lib/
├── core/ shared by every feature
│ ├── common/ User entity, AppUserCubit, shared widgets
│ ├── database/ AppDatabase — the only thing that opens SQLite
│ ├── error/ Failure (returned) and Exception (thrown)
│ ├── network/ ConnectionChecker
│ ├── theme/ usecase/ utils/ secrets/
├── features/
│ ├── auth/ domain · data · presentation
│ ├── tasks/ domain · data · presentation
│ └── sync/ domain · data · presentation
├── init_dependencies.dart GetIt: the one place concrete classes are chosen
└── main.dart app shell; also where features are connected
Rules the codebase actually keeps to:
- The domain layer is pure Dart. No Flutter, no Supabase, no SQL, no JSON. You could run it in a console app.
- Exceptions never escape the data layer. Data sources throw; repositories
catch and return
Either<Failure, T>. There is notry/catchanywhere in the domain or presentation layers. - Features never import each other.
authandsynchave no knowledge of one another; they are wired together inmain.dart, which is the app shell's job. Shared types such asUserlive incore/common. - Swapping Supabase for Firebase would mean rewriting
data/datasourcesanddata/models. Zero lines ofdomain/orpresentation/would change.
- Create a project at https://supabase.com.
- SQL Editor → run
offline_task_management_app/supabase/01_auth_schema.sql, then02_tasks_schema.sql. - Project Settings → API → copy the Project URL and the anon public key.
cd offline_task_management_app
cp lib/core/secrets/app_secrets.example.dart lib/core/secrets/app_secrets.dartFill in the Supabase URL, anon key, and your Google Web OAuth client ID. The real file is gitignored.
Two OAuth clients in one Google Cloud project:
| Client type | Used as |
|---|---|
| Web | googleWebClientId, and pasted into Supabase → Auth → Providers → Google |
| Android | package name + SHA-1; not referenced in code, but must exist |
Get the debug SHA-1:
keytool -list -v -alias androiddebugkey -keystore %USERPROFILE%\.android\debug.keystore -storepass android -keypass androidRelease builds are signed with a different key — register that fingerprint too before producing the submission APK, or Google sign-in works in debug and fails in release.
flutter pub get
flutter analyze
flutter test
flutter runBuild the APK:
flutter build apk --release
# output: build/app/outputs/flutter-apk/app-release.apkThis is the part worth demonstrating, in this order:
- Sign in once with internet on. Create two or three tasks and watch the banner go quiet as they sync.
- Turn on airplane mode. The banner turns amber: "Offline — your tasks still work."
- Create, edit, complete and delete tasks offline. Everything responds instantly. Unsynced rows show a small cloud-off icon. The banner counts the queued changes.
- Force-kill the app and reopen it while still offline. Everything is still there, including the queue — nothing was held in memory.
- Turn airplane mode off and do nothing. The queue drains by itself within a couple of seconds. No retry button needed.
- Check Supabase → Table Editor →
tasks. The rows are there with the same ids the device generated. - Multi-device: sign in on a second device and watch the tasks arrive. Edit the same task on both while offline, then reconnect both — the later edit wins and neither device ends up with a duplicate.
SQLite via sqflite, with hand-written SQL, rather than Hive or Drift.
The sync design needs real transactions (a task row and its queue row must
commit together), ordered queue processing, and indexed queries for search and
filtering. Hive is a key-value store and gives none of those. Drift would work
but adds a code-generation step; raw SQL keeps the schema and every query
visible in one file.
Device-generated UUIDs instead of database-generated ids. A task created in airplane mode needs an identity the moment it exists. It is also what makes retries safe: every push is an upsert keyed on that id, so sending the same change twice lands on the same row instead of creating a second task.
Soft deletes (tombstones). A row that is simply gone cannot tell the server it was deleted. The row is dropped for real only once the server has acknowledged it.
updated_at is set by the device, not by Postgres. Conflict resolution
compares it, so a server-side trigger overwriting it would make a change made
at 9:00 offline arrive stamped 17:00 and beat an edit genuinely made at 11:00.
- Conflict resolution is last-write-wins on
updated_at, so a device with a badly wrong clock can win a conflict it should lose. A production version would send the device timestamp and a server-assigned sequence number and break ties on the latter. - Sync runs while the app is alive. Backgrounded sync would need WorkManager (Android) / BGTaskScheduler (iOS).
- Tombstones accumulate in Postgres; a scheduled job should purge ones older than the longest plausible offline period.
- Tests cover the model layer. The local data source and sync engine are
written against interfaces and are testable with
sqflite_common_ffiand fakes, but those tests are not written yet.
docs/SYNC.md— offline storage, synchronisation and conflict resolution in detaildocs/AUTH_SETUP.md— auth setup and the full token flowclean_architecture_guide_code_reference.md— the architecture reference this project follows