Flutter and Laravel can form a productive application stack: Flutter owns the mobile experience, while Laravel owns business rules, authorization, persistence, jobs, and integrations. A written API contract connects the two, and every request the app may retry carries a key that stops it running twice. With both in place, one Laravel backend serves the iOS app, the Android app and the web dashboard.
We built a field service system for maintenance and HVAC companies this way. It has a web console for the office and a Flutter app for technicians, both on one Laravel backend. We have not released it to customers yet. The examples below come from its contract and code as they stood in November 2026, together with what we would change if we started today.
Define ownership before choosing packages
Write down which layer owns validation, authorization, prices, workflow transitions, and derived status. The client can validate for fast feedback, but the server must make the authoritative decision. Flutter owns navigation, local presentation state, device capabilities, and a safe offline queue. Laravel owns tenant and user context, durable records, policies, transactions, and external side effects. This division prevents two app versions from calculating the same rule differently.
| Decision | Flutter app | Laravel backend |
|---|---|---|
| Field validation | Quick check so the user sees the mistake at once | Final decision |
| Authorization | Hides what the user may not see | Checks every request |
| Prices and discounts | Shows what the server sent | Calculates them |
| Record status | Requests a transition | Accepts or rejects it |
| Offline work | Stores the operation in an encrypted queue | Applies it once when it arrives |
| Notifications, reports, outside providers | Shows the outcome | Runs them as queued jobs |
On the client, Flutter's architecture guide makes repositories the source of truth for app data. Our technician app has one repository for work orders. It fetches them from the server and saves them in the encrypted local store. It reads them back from there and puts every change into the sync queue. The screens reach work orders through it.
Write the API contract before the screens
An API contract states, for every endpoint, the request and response fields, their types, which may be null, and the errors the client can receive. We keep the technician API in an OpenAPI 3.1 file, the standard format for describing HTTP APIs. Its two main rules are that a breaking change gets a new major path and that clients ignore any field they do not recognize. The second rule lets us add a field to a response without crashing an older version of the app.
On the server, Laravel's API resources sit between your models and the JSON you return and decide which attributes each user sees. Give every resource a test that compares its output with the contract. A dropped field then fails your automated build checks instead of a technician's phone.
Keep the user session separate from the device
An access token, a registered device and a push token are three records with three lifetimes. Our backend registers the device at first sign-in. If a device is lost, the office can disable it, and the server then refuses its requests even while the token is still valid. The app keeps its token in the platform's secure storage through flutter_secure_storage and ships no server secret. The server checks authorization on every request, because hiding a button changes the screen and leaves the endpoint reachable.
Make every retry safe with an idempotency key
An operation is idempotent when sending it twice has the same effect as sending it once. The app creates a unique key for each operation and stores it with the operation in the local queue. It sends that key in an Idempotency-Key header on every attempt.
The server stores the key, a hash of the request and the response. If the same key arrives again within 24 hours, which is how long our backend keeps it, it replays the stored response without running anything. If the same key arrives with different data, it returns 409. A retry inside that window after a dropped connection therefore cannot create a second appointment or a second payment. Keep keys longer than the longest outage you expect.
On the Laravel side, simplified from our code:
// routes/api.php
Route::middleware(['auth:sanctum', 'mobile.device'])->group(function (): void {
Route::middleware('field.idempotency:required')->group(function (): void {
Route::post('/work-orders/{workOrder}/status', [MobileWorkOrderController::class, 'changeStatus']);
});
});
// MobileWorkOrderController::changeStatus
$data = $request->validate([
'to_status' => ['required', 'string', 'max:40'],
'base_version' => ['required', 'integer', 'min:1'],
'reason' => ['nullable', 'string', 'max:500'],
]);
$updated = $this->workOrders->changeStatus(
$workOrder, $target, $user, $data['reason'] ?? null, (int) $data['base_version'],
);
On the Flutter side, from the technician app's sync service:
// The operation was stored in the local queue with its key when it was created
final ApiResult result = await _api.request(
method: operation.method,
endpoint: operation.endpoint,
data: operation.payload,
correlationId: operation.correlationId,
idempotencyKey: operation.idempotencyKey,
);
base_version is the work order's version as the technician last saw it, and our backend raises that number with every status change. If the work order's status has changed on the server since then, the server returns 409 and leaves the newer change in place.
Map each error to app behavior
| HTTP status | Meaning | What the app should do |
|---|---|---|
| 401 or 403 | Session expired or device disabled | Stops sending, locks sensitive screens, keeps encrypted drafts, asks the user to sign in |
| 409 | Conflict with a newer server version | Keeps the operation pending as a conflict, fetches the current record, offers the user a choice |
| 422 | Invalid data or a transition that is not allowed | Shows the error and asks for a correction; never resends unchanged |
| 429 | Rate limit reached | Waits for the Retry-After period |
| 5xx or no network | Server or network failure | Retries with growing intervals and the same key |
If we started today, we would change how the server reports errors. Our backend reports an error as an HTTP status and a text message only, so the app can act on the status alone. That leaves 409 covering several cases: a version conflict, a key reused with different data, and a request whose key is still being processed.
We would give every error a stable code in the Problem Details format of RFC 9457. That IETF standard describes HTTP API errors in JSON. A version conflict would look like this:
{
"type": "https://api.example.com/problems/version-conflict",
"title": "The work order changed on the server",
"status": 409,
"code": "version_conflict",
"current_version": 8
}
Keep the user-facing wording in the app, in every language it supports. Then test the case where the server sends a code an older app does not know.
Design offline work as a queue of operations
List the tasks that work offline. In our system a technician can read assigned work orders, change their status, fill in the checklist and capture photos. The app needs the network for first sign-in and for confirming a payment with an outside provider. It also needs it to close a work order while a conflict or a required upload remains.
The app stores each operation in an encrypted SQLite database (SQLCipher) together with its key and the version it was based on. When the network returns, it runs one cycle in a fixed order:
- It revalidates the access token and the device.
- It fetches the current settings from the server.
- It pulls every change since the last saved cursor (the point where the previous sync stopped). If a work order has been unassigned from this technician, it deletes the work order and its pending operations before sending anything.
- It replays pending operations, then photos, each with its own key, resuming any upload from the last accepted chunk.
The cursor moves only after a whole batch of changes is saved in one transaction. A second connectivity event during the cycle joins it instead of starting a parallel run.
Resolve conflicts by data type
Our sync contract sets a policy for each kind of change, and we are still testing some of them on real devices:
| Change | Policy in our sync contract |
|---|---|
| New note or time entry | Added if the work order is still assigned to the technician; a repeated key adds nothing |
| Status transition | Checked against the current state; a transition that is not allowed is rejected |
| Completion evidence | New photos are merged; completion stays blocked until requirements pass |
| Assignment or schedule | The dispatcher's change stands; the technician sees the conflict and the refreshed work order |
| Customer and site data | The server version stands; the technician's draft is kept for review |
| Cancellation | The cancellation stands; the technician's attempt is kept in the log as rejected |
"Last write wins" silently drops one side's edit. Use it only for a field where you have accepted that loss in writing.
Move slow work to queued jobs
Send notifications, reports, file processing and provider calls to a Laravel queue. Return an "in progress" state to the app, with an endpoint where it can ask for the result. Dispatch those jobs after the database transaction commits (afterCommit). If the transaction rolls back, Laravel discards the job, so no notification goes out about something that was never saved. Laravel attempts a job once unless you set the number of tries, and its default timeout is 60 seconds, so set both for every job.
Trace one request across the boundary
The technician app sends a correlation ID in an X-Correlation-ID header with every request and stores it with the queued operation. Pass that ID from Laravel into queued jobs and provider logs. Show it in the error message so the user can quote it to support. Support can then follow the operation from the phone to its last step.
Log app version, error type and latency, and keep screen content and tokens out of the logs. Server CPU tells you little about what the user sees, so watch latency and error rate per endpoint.
Protect compatibility across releases
Users do not all update on the same day, so the backend serves several app versions at once. Decide the oldest version you support and send it in the settings response. Make every change additive: add a new field and leave the meaning of existing fields alone.
Our backend already sends the oldest supported version as min_app_version. The technician app does not act on it yet, so an older app keeps running without a prompt. Read that value from your first release, and ask the user to update when the installed version is older than that value.
Before any contract change, run this drill:
- Run the oldest supported app and the newest app against a test server that carries the change.
- Add an optional field and check that the old app ignores it.
- Add a new status value and check that the old app shows it with a generic label instead of crashing.
- Trigger an authorization error and a dropped connection mid-upload on both versions.
- Record who approved any breaking change, when the old path will be retired, and the message an old-version user will see.
Then release in order:
- Deploy the additive server changes first, so both app versions keep working.
- Ship the app to both stores and watch how many users sit on each version.
- Put any feature you may need to switch off behind a feature flag, with an owner and a removal date.
- Prepare a server rollback that keeps the data the new version has written, and test restoring critical records from backup.
- Name who watches the first hours after release, and write down how they turn off one provider or feature while the app keeps running.
Test contract, device and failure together
Backend tests cover authorization and response shape; app tests cover parsing and screen state. Only a real device shows how camera permissions, background limits and secure storage behave. In our system, the Android integration suite opens the real encrypted database. It checks that photos upload again after the connection returns, and that a stored conflict holds back later operations on the same work order. Other real-device runs, such as the OS killing the app under memory pressure, remain release gates.
When Firebase or Supabase is enough
We have built other Flutter apps on hosted backends. The customer and driver apps for WATR, a water delivery company related to BarmajTek, run on Firebase, with Cloud Functions for the server logic. The customer and store apps for Labeeni, an auto-parts marketplace, run on Supabase, with row-level security in PostgreSQL.
A hosted backend fits when permissions can live in the database and a few functions cover the rest of the logic.
We choose Laravel when many rules must be decided on the server. Our field service system is one such case. Its server decides work order states, dispatch and invoicing, and keeps each company's data apart from every other company's.
Next step
If you are planning a Flutter app on a Laravel backend, send us two real workflows and the oldest app version you expect to support. We will review the contract and its failure paths with you as part of our mobile app development service. The guide to offline-first progressive web apps (PWAs) applies the same queue to web apps. The Clean Architecture and DDD in Laravel guide shows how we arrange business rules on the server. To ask directly, message us with the WhatsApp button on this page. When your app is ready for the stores, the steps are in How to Publish an App on Google Play and the App Store.




