Newton Institute of Technology Logo
Newton Institute of Technology Building Your Dream Career

Offline-First Mobile App: How to Sync Data Safely

NIT Practical Mobile Development Guide

How to Design an Offline-First Mobile App That Syncs Safely

Build for weak networks, interrupted uploads and two phones editing the same record. Learn how to save work locally, sync it reliably and show users what really happened.

Flutter-friendly Real field-survey example Failure tests included

For: ICT students, Flutter learners, mobile developers and software teams. Last reviewed: 17 November 2026. Illustration: fictional farm-inspection records; no real personal data.

The quick answer

What makes an offline-first mobile app safe?

An offline-first mobile app keeps essential work usable when the internet is unavailable. For safe synchronization, save each edit locally and record its pending operation in one transaction; retry the same operation ID until the server acknowledges it; check record versions before merging; and show the user whether work is saved locally, confirmed remotely or needs review. Reconnecting to the internet does not mean syncing succeeded.

1. What Is an Offline-First Mobile App?

Imagine visiting a farm where your phone has no mobile signal. You open your inspection app, complete a form, save the visit and close the phone. Later, when you reach a place with coverage, the record appears on the organisation’s server without needing to type it again.

That is the central idea of an offline-first app: important tasks can work using data stored on the device, and a connection is used to share and reconcile changes when available. This does not mean every feature must work without internet. Some actions, especially those needing central approval, may correctly remain online-only. Google’s Android and Flutter guidance both make that distinction. [1] [2]

Online-only app

Must contact a server before completing most tasks. With no usable connection, the form may fail or become unavailable.

Cached app

Can display previously loaded information but may not reliably store new changes for later delivery.

Offline-first app

Reads and saves essential work locally, then manages later synchronization and possible conflicts.

Important distinction

“Saved on this phone” and “received by the server” are two different guarantees. The interface must not label a record “synced” until the app has obtained and durably recorded a valid server acknowledgement.

2. The Five Parts of a Reliable Offline-First Architecture

Start with a small system you can explain. The app interface should read from local storage rather than waiting for every network request. The repository coordinates that storage with a background synchronization service.

1 · Local database

Holds the current records and lets screens work when the device is disconnected.

2 · Data repository

Provides one controlled place for reading, editing and coordinating local and remote state.

3 · Durable outbox

Stores a record of changes waiting to be transmitted; survives restarts.

4 · Sync worker

Pushes pending operations, receives acknowledgements, downloads changes and retries failures.

5 · Backend API

Authenticates users, checks permissions, deduplicates operations, assigns record versions and publishes changes.

Design principle

The server decides authoritative shared state; the local database is the immediate source for the app’s display.

Architecture path: Form → local database and outbox (one transaction) → sync worker → authenticated API → server database. Server changes then flow through the sync worker back into local storage and onto the screen.

For a first project, prefer a single repository and one carefully designed synchronization path. Adding many background jobs before the data model is correct makes failure handling harder to understand.

Five rules that must never become false

The application can stop at any moment. These five invariants—conditions that remain true after each successful transaction—make the design testable.

  1. No orphaned write: A locally committed edit has a corresponding durable pending operation, or its accepted server outcome is already recorded.
  2. No changed retry: Once an operation may have left the phone, its operation ID and meaning never change. A new edit needs a new ID.
  3. No false confirmation: An older acknowledgement cannot mark a newer revision as synchronized.
  4. No silent conflict: A server-version mismatch preserves the local proposal for review.
  5. No skipped change page: Remote changes and the cursor that covers them commit together, or neither commits.

These are design targets—not a guarantee that a destroyed device can never lose unsent data. Plan recovery and backups when work is irreplaceable.

3. A Realistic Example: A Farm Inspection App

Our fictional field officer, Amina, visits a farm in Migori County. She creates visit VISIT-184, records crop observations, and attaches a photo. The phone has no coverage.

ActionWhat the phone doesWhat the officer sees
Save with no signalCommits the visit and a pending outbox operation locallySaved on this device · Pending sync
Close and reopenLoads the same record from the databaseRecord remains available
Connection returnsRetries the queued operation using its existing IDSyncing
Server acceptsRecords the acknowledgement and server versionSynced · Time of confirmation
Another device changed itPreserves the local work and displays the conflictNeeds review · Nothing discarded

On a phone, swipe sideways within the table to read every column.

The harder test comes after Save: Amina loses the network, reopens the app, edits again, and learns that someone else changed the same visit. The system must preserve both sets of work.

Decide which actions may happen offline

Good offline-first products set limits deliberately. Notes, drafts and inspections can often be saved locally. A payment transfer, inventory reservation or irreversible approval may need a server response before the UI can truthfully claim that the business action succeeded.

Offline allowed

Draft visit, edit notes, capture a photo, browse previously downloaded assignments.

Pending confirmation

Submit visit, upload attachments and assign a server-issued receipt number.

Online-only where required

Financial settlement, shared stock commitment and centrally authorised decisions.

4. Design Local Storage Before the Sync Logic

A structured database such as SQLite is suitable for many mobile applications because it can persist related records and support transactions. Choose an appropriate Flutter database integration and ensure its storage, migrations and encryption meet your application’s needs. Plain SQLite is not automatically an encrypted database.

For our illustration, we need visits and outbox tables. The outbox is a durable record of work the device still needs to send. The server_version describes the last confirmed server revision; local_revision increments whenever the person changes the device copy. Those numbers answer different questions. A later server reply must not erase a higher local revision.

CREATE TABLE visits ( id TEXT PRIMARY KEY, farm_name TEXT NOT NULL, notes TEXT NOT NULL, server_version INTEGER, local_revision INTEGER NOT NULL DEFAULT 0, sync_state TEXT NOT NULL DEFAULT 'pending' ); CREATE TABLE outbox ( operation_id TEXT PRIMARY KEY, entity_id TEXT NOT NULL, action TEXT NOT NULL, payload_json TEXT NOT NULL, base_version INTEGER, local_revision INTEGER NOT NULL, state TEXT NOT NULL DEFAULT 'pending', FOREIGN KEY (entity_id) REFERENCES visits(id) );   — Example: preserve server_version on update INSERT INTO visits(id, farm_name, notes, local_revision) VALUES(‘VISIT-184’, ‘Example Farm’, ‘First note’, 1) ON CONFLICT(id) DO UPDATE SET farm_name = excluded.farm_name, notes = excluded.notes, local_revision = visits.local_revision + 1, sync_state = ‘pending’;

Read the example: Each visit uses a stable client-generated ID. The outbox keeps a separate operation ID, its payload, the server version it was based on, and whether delivery is still pending. Production schemas also need indexes, schema migrations, and account or tenant isolation (for example, separate per-account databases or tenant-qualified keys). Enable and test foreign-key enforcement in the chosen SQLite integration. The SQL upsert shown here changes only the visit row; the outbox insert must be made inside the same transaction as illustrated next.

5. Save the Record and Queue the Change Atomically

When Amina taps Save, do two local writes inside one database transaction: update the visit and insert the outbox operation. If either write fails, roll back both. Without this rule, the app might show a saved visit that has no corresponding operation to upload. An existing visit must be updated rather than inserted as a second record; in SQLite, INSERT … ON CONFLICT DO UPDATE is one option. [5]

Here is Flutter-style pseudocode. The findVisit, upsertVisit, addOutbox and newOperationId helpers stand for repository methods you must implement with your selected SQLite library. The important part is that the current local revision is read and incremented inside the transaction; a screen-supplied revision could already be stale.

Future<void> saveVisitOffline(Visit draft) async { await db.transaction((txn) async { final saved = await txn.findVisit(draft.id); final revision = (saved?.localRevision ?? 0) + 1; final opId = newOperationId(); await txn.upsertVisit( draft, localRevision: revision, state: 'pending'); await txn.addOutbox({ 'operation_id': opId, 'entity_id': draft.id, 'action': saved == null ? 'create' : 'update', 'payload_json': draft.toJsonString(), 'base_version': saved?.serverVersion, 'local_revision': revision, 'state': 'pending', }); }); }

Read the example: If the visit already exists, update its local row instead of attempting a duplicate insert. The example creates a new logical operation for each edit. For one record, send edits in a defined order; coalesce only unsent edits if your rules allow it, and track any dependent later change until the preceding operation has been acknowledged. Once an operation has been transmitted, preserve its ID and payload on retries.

Why the transaction matters

If the phone runs out of space halfway through saving, either both the visit and the outbox entry should commit or neither should. Example: Amina edits VISIT-184 twice while offline. Both edits remain represented by durable local state and pending operations; a later acknowledgement for edit 1 must not mark edit 2 as synced. Keep each acknowledged operation separate from the current local record revision.

When the user edits again before syncing finishes

Imagine local revision 3 was sent and Amina has already created revision 4. The server acknowledges revision 3 as server version 8. The device records that result against revision 3, but keeps revision 4 pending. It must not replace the displayed revision 4 with the older server response. Before transmitting the next unsent update, base it on the acknowledged server version 8. Sequence later edits after their prerequisite operations, or combine edits that have definitely never been sent. Never modify the payload of an operation already submitted under the same ID.

6. Design a Safe Push-and-Pull Synchronization Cycle

Synchronization is not one giant “upload everything” command. Treat it as a repeatable sequence that can stop halfway and start again without losing information.

  1. Check eligibility: Is the user authenticated, the network actually reachable, and the local store unlocked?
  2. Push pending operations: Send a bounded batch using original operation IDs. Keep one in-flight mutation per record unless the server contract supports another ordering model. Create the visit before sending its photograph.
  3. Process individual results: Persist each acknowledgement or rejection durably. Keep transient failures for later retries. Handle an older operation acknowledgement without resetting newer local edits to “synced.”
  4. Pull server changes: Request changes since the last durable cursor; include updated records and deletion markers.
  5. Apply and checkpoint atomically: Apply each server change page and its next cursor in one local transaction. Do not overwrite locally pending edits with an older remote snapshot; store the incoming version for conflict review when needed.
  6. Repeat carefully: Run another pass if new work arrived. Apply bounded exponential backoff with jitter for transient failures; do not endlessly retry a rejected permission or invalid-data request without intervention.

Internet connectivity indicators are only hints: being connected to Wi-Fi does not guarantee that the application’s API is reachable. A request and valid response provide better evidence of availability. Timeout or temporary server failure: retry later with the same operation. Expired login: pause protected work and seek re-authentication. Version conflict: preserve the edit for review. Permanent validation failure: show the error and allow correction rather than silently deleting the operation.

A simple synchronization API contract

Keep endpoints explicit. For example, POST /sync/operations can accept mutations, while GET /sync/changes?cursor=… returns versioned changes and an opaque nextCursor. The server defines ordering, authorization scope and page boundaries. After applying a page and storing that cursor in the same transaction, restart safely from the saved cursor. If the server reports an expired cursor, re-bootstrap remote data while preserving all pending local operations.

A two-edit race: follow the exact versions

Suppose Amina edits a visit again after the first request has left the phone but before its acknowledgement arrives.

MomentClient stateSafe action
Save #1Local revision 1; OP-1 pendingPersist record and OP-1 together
Send OP-1OP-1 durably marked ever attemptedFreeze ID, action, payload and base version
Save #2Local revision 2; OP-2 queuedPreserve revision 2; wait for OP-1
Server accepts OP-1Server version 1 returnedAcknowledge only OP-1; keep OP-2 pending
Before first send of OP-2OP-2 definitely never transmittedRebase to server version 1; then freeze and send
Server accepts OP-2Server version 2 returnedMark synced only when no newer edit remains

On a phone, swipe sideways within the table to read every column.

Critical: Store that an operation may have been sent before issuing its HTTP request. Only an operation proven never sent may be rebased in place. If one was attempted, retry the exact request or resolve a conflict using a new operation ID.

Serialize dependent edits for the same record; independent records may sync with bounded concurrency.

{ "operationId": "OP-7f6b", "entityId": "VISIT-184", "action": "update", "baseVersion": 7, "payload": { "farmName": "Example Farm", "notes": "Inspect irrigation line" } }

Read the example: This is an update to an existing visit, so its base version is 7. A newly created visit instead uses its own unique entity ID and no prior server version. If the request times out, the client retries with the same operationId and unchanged payload. A different user edit should become a new operation with a new ID; do not mutate the meaning of an existing operation.

7. Prevent Duplicate Effects When an Upload Is Retried

Here is a dangerous but ordinary failure: the server saves VISIT-184 and sends its response, but the phone loses connection before the response arrives. The phone cannot tell whether the operation succeeded. It must retry.

Reliable systems normally use retryable, at-least-once requests with idempotent server processing: one logical operation may be transmitted several times while the server commits its effect once within the documented deduplication window. Do not confuse this with exactly-once network delivery.

First attempt

Server validates the operation, applies its effect and records the operation ID and response in the same transaction.

Response lost

The phone never records the acknowledgement, so the operation remains pending.

Same-ID retry

Server recognizes the previously accepted operation and returns the recorded outcome without applying the effect again.

The server’s deduplication ledger must be durable, scoped to the correct tenant or authorized account, and protected by a unique constraint so simultaneous retries cannot both apply the effect. The operation and its stored outcome must commit together. If the same ID arrives with a different payload, reject it; document how long the server retains deduplication records, because retries after expiry can otherwise reapply an effect. These practices align with the emerging IETF Idempotency-Key draft, which is still a draft rather than a finalized standard. [6]

BEGIN TRANSACTION authenticate and authorize request look up operation ID in durable receipt ledger if already completed: return stored result verify request payload and base version apply operation or record a conflict result store operation ID, payload hash and result COMMIT return stored result

Read the example: This is language-independent algorithm notation, not executable SQL. The receipt record and business mutation must be committed atomically. The real system also needs explicit error classes, concurrent-request locking and a documented deduplication-retention policy.

What the server must commit in one transaction

For each authorized tenant and operation ID, serialize competing first attempts, compare a stable request fingerprint, conditionally change the record and store its result in the same database transaction. A unique receipt constraint or transaction-level lock must prevent concurrent retries from both applying the effect. If a duplicate arrives while the first is in flight, it can wait or receive a documented processing response; it must not execute the mutation again.

A version check may use a conditional statement such as UPDATE visits SET notes = ?, version = version + 1 WHERE id = ? AND version = ? and inspect its affected-row count, with tenant and authorization enforced separately. No match means conflict, not permission to overwrite. Actual concurrency behavior depends on the database and isolation design.

Two Save taps are different from a retry. If a double tap creates two new operation IDs, an idempotency receipt does not automatically merge them. Prevent unintended repeat actions in the UI or enforce a business-level uniqueness rule.

8. Handle Two Phones Editing the Same Record

Suppose Amina opens visit version 7 while offline. Another officer, Otieno, edits the same visit online and creates version 8. Amina later submits an edit based on version 7. Simply replacing version 8 with her record would silently discard Otieno’s work.

A safer general approach is optimistic version checking. The client sends its base version. The server conditionally applies the change only while that version is current, or performs a documented domain-specific merge. If the version no longer matches, it returns the latest server record and a conflict result; the original local proposal remains available. A separate later operation can submit the reviewed result against the new server version.

Conflict strategyAppropriate useMain danger
Last write winsLow-consequence data where overwriting is acceptable and ordering rules are definedSilent loss of another user’s edit; device clock disagreements
Reject on version mismatchImportant shared records that need explicit reviewUser needs a clear recovery path
Field-level mergeIndependent fields with known safe merge rulesApparently separate fields may contain related business meaning
Manual conflict reviewHigh-consequence or ambiguous competing editsRequires good interface design and audit evidence

On a phone, swipe sideways within the table to read every column.

Never treat timestamps as a universal solution

Device clocks can be wrong, two edits can have different business priority, and overwriting a record may have real consequences. Choose conflict policies per type of data, not as a single global default.

What Amina should see

Show both versions, their authors where appropriate, and the fields that differ. Offer actions such as keep server version, submit a reviewed merge or save as separate draft. Keep the rejected local proposal intact until the selected resolution is durably stored. If Amina merges her irrigation note with Otieno’s crop observation, create a new operation ID based on the current server version instead of rewriting the rejected operation.

9. Deleted Records, Photos and Interrupted Attachments

Use deletion markers rather than silently removing history

If the server simply removes a record, a phone that was offline may never learn that it was deleted. Many systems therefore publish a tombstone—a versioned deletion marker—through their change feed. Devices apply that marker as part of incremental sync. If a phone has been offline longer than the server retains these markers, it may need a complete, safe re-bootstrap. A re-bootstrap must reconcile authoritative server deletions with unsent edits; simply clearing the local database first could destroy the user’s only copy of pending work.

Treat file uploads separately from record acknowledgement

Amina’s visit metadata might sync successfully while the photograph is still uploading. Track attachment state independently, reference files using a stable attachment ID, check upload integrity, and retry incomplete transfers safely. Do not mark the photo “uploaded” merely because the visit row reached the server.

Record state

Saved locally → Pending → Sent → Acknowledged or Conflict.

Attachment state

Local file → Upload pending → Uploading → Verified or Failed.

Deletion state

Delete requested → Server tombstone → Devices remove or archive local copies as policy permits.

Before deleting local media, confirm the server has the right bytes and any required processing is complete. For large files, use a supported resumable upload protocol and verify file size or checksum where practical. A visit being marked “synced” does not imply its photograph is verified. Retention and legal-deletion requests need deliberate policies so permanent offline copies do not linger unnoticed.

10. Protect Local Data and the Sync API

Offline-first expands the places where information exists. A secure server does not compensate for a phone that exposes personal records, photos or long-lived credentials. OWASP MASVS provides a recognised set of mobile storage-security requirements. [3]

  • Protect the database: Minimise sensitive local data, use appropriate encryption and platform-backed secret management, and avoid storing API tokens in ordinary unprotected preferences.
  • Use authenticated HTTPS: Authenticate every sync request and authorize every record operation on the server. A client-supplied entity ID must never bypass tenant or user permissions.
  • Plan for expired sessions: Pause protected uploads until re-authentication; keep legitimate unsynced work securely stored rather than silently dropping it.
  • Separate accounts: Do not show one user’s local cache after another user signs in. Give careful warnings and a safe handoff or recovery policy before destructive logout actions.
  • Reduce leakage: Avoid private records, tokens, full request payloads and GPS histories in debug logs, analytics or backups.
  • Make sync auditable: Record a minimal history of local creation, server acceptance, conflicting versions and resolved decisions without exposing unnecessary personal details.

For Kenyan applications processing personal information, the Office of the Data Protection Commissioner describes principles including purpose limitation, data minimisation, storage limitation and confidentiality. Use these to guide what the app collects, caches and retains. This tutorial is technical education, not an exhaustive legal-compliance assessment. [4]

Cursor and permission rules for real accounts

Each sync cursor belongs to an authenticated account, tenant, dataset and change-feed contract. Never reuse a cursor after switching accounts. An authorized change feed must also handle deletions and changes in access, with a safe re-bootstrap path when retained history expires.

A phone that remains offline cannot instantly receive an administrator’s access revocation. The server must reject unauthorized operations when connectivity returns, while the device follows a defined local-cache and session policy. Do not promise immediate remote wipe while the phone is disconnected.

11. How to Assemble the Example in Flutter

Flutter’s official offline-first guide explains a repository that coordinates local and remote services. Use the same conceptual layering for our field-survey app. [2]

  1. Form: Validate the visit fields and submit to a repository, not directly to an HTTP function.
  2. Repository: Save locally and enqueue the operation in one transaction.
  3. Storage layer: Persist visits, outbox operations, sync cursor, conflicts and attachment state.
  4. Sync coordinator: Serialize work per entity where needed, persist retry decisions and process server responses without overwriting newer local edits.
  5. UI state: Observe the local database and display precise pending, confirmed and conflict statuses.

The next snippet is a control-flow sketch, not a complete Dart package. The store and api services stand for interfaces you implement. In particular, recording acknowledgements and merging pulled pages must each use correct local transactions; a scheduler must prevent overlapping sync workers.

Future<void> runSync() async { if (!await store.acquireSyncLease()) return; try { for (final op in await store.readyOperationsInOrder()) { await store.markEverSent(op.id); // Before HTTP try { final reply = await api.send(op); if (reply.isAcknowledged) { await store.ackAndRebaseOnlyUnsent(op, reply); } else if (reply.isConflict) { await store.preserveConflict(op, reply); } else if (reply.requiresLogin) { await store.pauseForLogin(op); break; } else if (reply.isPermanentRejection) { await store.keepForCorrection(op, reply); } else { await store.deferRetry(op); } } on NetworkException { await store.deferRetry(op); // Same ID, same body } } await store.pullPagesWithAtomicCursor(api); } finally { await store.releaseSyncLease(); } }

Read the example: The worker must handle request exceptions, distinguish retryable errors from permission or validation failures, and avoid overlapping runs. It must persist the attempted flag before transmitting. Its acknowledgement handler should mark only the acknowledged outbox operation complete; update the visible record to “synced” only when no newer local revision is pending. When a pull response and an unsent edit concern the same visit, keep both for conflict processing.

Make the interface tell the truth

Visible statusWhat it means
Saved on deviceThe local transaction succeeded; upload may not have started
Pending syncA durable operation is waiting for a suitable connection
SyncingA transmission or reconciliation attempt is in progress
SyncedThe app has recorded a valid server acknowledgement for the latest relevant operation
Needs reviewThe server rejected or conflicted with a change, and local work remains accessible

On a phone, swipe sideways within the table to read every column.

Background syncing is best effort, not an instant-delivery guarantee

Run sync on app launch, after a local save, on a usable connectivity change and through supported background scheduling. Operating systems can delay or suspend background jobs for battery, network or platform reasons. Android’s WorkManager supports persistent work, while Flutter documents the corresponding practical constraints. Neither guarantees immediate or continuous sync on every device. [1] [2]

Provide Sync now and a truthful last-confirmed time when this matters to the user. Prevent overlapping workers, recover after process termination and treat connectivity indicators as hints rather than proof that the API is working.

12. Test the Failures, Not Only the Happy Path

A synchronization demo that works once on strong Wi-Fi is not evidence of a reliable offline-first system. Use fictional data, two devices or emulators, and a backend test environment.

Test scenarioExpected safe result
Save in airplane modeRecord remains after a full app restart; outbox entry remains pending
Lose internet after server commitRetry same operation ID; server applies business effect once
Tap Save twice rapidlyClient blocks unintended second action; separate operation IDs are not automatically duplicates
Two devices edit version 7Server detects a stale-version conflict; neither edit disappears silently
Worker interrupted mid-batchPreviously committed acknowledgements survive; remaining operations retry
New edit arrives while old upload is in flightOld acknowledgement clears only its operation; newest local revision remains pending
Power loss while applying sync pageRemote records and next cursor both commit, or neither does; page is safe to replay
Reuse operation ID with modified payloadServer rejects key reuse; no second business effect is applied
Server deletes a recordOffline client later sees the deletion marker or performs safe re-bootstrap
Photo upload fails at 80%Metadata remains correct; attachment stays pending until verified
Access token expiresProtected sync pauses and resumes after safe re-authentication; local data is protected
Local storage becomes fullFailed transaction does not leave an orphaned outbox operation or half-saved visit
Different account logs inPrevious account’s private offline records do not become visible to the new user
Device offline for monthsExpired cursor is detected; re-bootstrap preserves pending local edits

On a phone, swipe sideways within the table to read every column.

Mark each test as pass, fail or not run; keep screenshots, server receipts or database inspection evidence for the outcome.

A demonstrable portfolio test

Show a visit saved in airplane mode, restart the app, reconnect, intentionally lose an acknowledgement, retry the same operation ID and verify that the server has one logical result. Then edit that record locally while an earlier operation is in flight: the newer edit must remain pending after the old acknowledgement. Finally, create a two-device conflict and resolve it without discarding either person’s proposed content.

A small executable verification exercise

Make a miniature local and server database, then test eight outcomes: local rollback, lost acknowledgement, changed-payload rejection, older acknowledgement, stale-version conflict, dependent edits blocked during conflict, atomic cursor rollback and account-scoped receipt keys.

A simulated SQLite model can verify state transitions; a real Flutter app and authenticated API still require integration, device, encryption, background and network-race testing.

13. Common Offline-First Mistakes and Their Corrections

Clearing the queue too soon

Do not delete pending work because a request started; wait for a valid server response recorded durably.

Blindly overwriting changes

Keep base versions and define a conflict policy that fits the business meaning of each record.

Assuming Wi-Fi means success

Distinguish network connectivity, API reachability, valid authentication and successful record acknowledgement.

Recreating operation IDs

Retried delivery of the same mutation must retain the same stable ID and payload.

Ignoring local storage failures

Test disk-full conditions, database corruption recovery, migrations and unsafe logout scenarios.

Trying to sync everything

Download only authorized, relevant records. Use bounded batches, pagination and suitable background-work constraints.

Remember: a reliable architecture is a set of data guarantees, not merely a choice between Flutter, Firebase, REST or SQLite.

Frequently Asked Questions

Can a Flutter app work without internet?

Yes. Flutter apps can use local databases and offline-first repositories so essential screens and saves work without connectivity. The exact available features depend on how the app has been designed. [2]

Does SQLite automatically sync data to a server?

No. SQLite stores and queries local data. Unless you use a separate synchronization layer or a managed service with defined sync support, you must build the operations, API, retries, conflict policies and acknowledgements yourself.

Should I use Firebase or build a custom sync system?

Use managed synchronization when its data model, conflict behavior, access controls, offline support and cost fit the application. Build custom synchronization when business operations, backend ownership or consistency rules require behavior the service does not offer. Test the real offline and conflict requirements before choosing.

How can I prevent duplicate records after reconnecting?

Assign a stable ID to each logical mutation, preserve it on retries, and require the server to deduplicate atomically with the database change. Also distinguish duplicate button presses from retries of one accepted user action.

What happens if two phones edit the same record offline?

When the changes arrive, the server should compare versions and apply a defined merge policy or report a conflict. Important edits should not disappear merely because one phone synchronized last.

Can offline-first apps guarantee zero data loss?

No architecture can promise zero loss in every event, such as a destroyed device before any successful upload or recoverable backup. Design to minimize loss through durable storage, appropriate backup strategies, observable pending state, atomic transactions and robust tests.

Is offline-first suitable for payments and inventory?

It can support offline drafting and queued requests, but a local “saved” action must not be confused with final financial or inventory approval. Operations requiring authoritative shared state should confirm their success against the server and handle duplicate attempts explicitly.

Does background sync always run immediately after reconnecting?

No. Mobile operating systems can delay background work. Persist pending operations, schedule supported jobs, retry when the app is reopened and show accurate pending or confirmed status. [1] [2]

What to Build Next

Start with one offline form and a local database. Add an outbox. Implement one idempotent server operation. Then deliberately break the network and prove what happens. Only expand to multiple record types, large attachments and complex merges when the first path is dependable.

For another portfolio idea, see NIT’s ICT portfolio projects guide, which includes an offline event check-in application. To understand where Flutter sits within a learning path, read mobile app vs web development and mobile developer career skills.

References and Technical Reading

  1. [1] Android Developers — Build an offline-first app. Local data, synchronization, write strategies, conflict resolution and WorkManager.
  2. [2] Flutter documentation — Offline-first support. Repositories, local/remote data, reads, writes and background sync.
  3. [3] OWASP MASVS — Storage. Mobile storage protection and prevention of sensitive-data leakage.
  4. [4] Kenya Office of the Data Protection Commissioner — Personal Data Protection Handbook. Core data-protection principles.
  5. [5] SQLite — UPSERT documentation. Updating existing records using ON CONFLICT DO UPDATE.
  6. [6] IETF HTTPAPI — Idempotency-Key Header (Internet-Draft). Operation keys, reuse and expiration; not a final RFC.

Code snippets and the field-survey example are original educational illustrations. They show architectural patterns; they are not a production-ready codebase or evidence that a deployed app has passed security testing.

Develop skills you can demonstrate

Learn to Build Mobile Apps With Newton Institute of Technology

Explore NIT’s Mobile App Development training in Dart and Flutter. The worked example in this guide shows why a mobile developer should understand local storage, APIs, user feedback and software testing alongside interface design.

Core technologyDart + Flutter

Develop cross-platform mobile applications.

Practical learningProjects + testing

Apply mobile, API and storage concepts.

Next stepExplore the course

Read the official course information and entry details.