I maintain openPOS, an open-source point-of-sale app written in Flutter. It is built for a single shop, a single device and a single person at the counter. The one rule I will not bend is that the app's own code makes no network calls. This post covers how that rule is enforced in the repo, and what it costs.
Why offline-first is a constraint, not a feature
Most POS apps start as a cloud product and add an "offline mode" later. That leaves you with sync queues, conflict resolution, auth tokens and a backend someone has to pay for and keep running. A small shop pays for all of that in monthly fees and in dependence on a vendor staying in business.
I went the other way. If the app has no network code, a whole class of problems is gone:
- No account, no login, no server to go down.
- The app never sends your data anywhere. (The phone's own backup, Google or iCloud if it is on, may still include app data; more on that below.)
- No SDK is quietly phoning home on the shop's behalf.
- The app behaves the same in a farmers market with no signal as it does on office wifi.
The key word is "constraint". A preference gets eroded one convenient package at a time. A rule written into the repo, and backed by the Android release manifest, is harder to erode. The project's CLAUDE.md states it flatly: never add outbound network calls, never add packages that fetch resources at runtime, never re-introduce the deleted sync scaffolding (outbox queue, sync service, connectivity provider, cloud backup). Anyone, human or tool, who opens a pull request is working against that file.
How the build blocks the network
Policy is easy to write and easy to forget, so the stronger guarantee is in the Android manifest.
The release build strips the INTERNET permission. The relevant file is android/app/src/release/AndroidManifest.xml:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.INTERNET"
tools:node="remove"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"
tools:node="remove"/>
</manifest>
Why is remove needed at all, if the main manifest never asks for it? Because permissions merge in from dependencies. The Star printer SDK ships INTERNET and ACCESS_NETWORK_STATE in its own manifest, since it also supports LAN printers. The app only uses Bluetooth, so the release manifest strips them back out during manifest merging. Debug builds keep INTERNET, because the Flutter tool needs it for hot reload.
An Android app without INTERNET cannot open sockets, so even if some dependency tried to reach out, the OS would refuse it. This proof is Android-only: there is no equivalent OS-level network block on iOS, where the guarantee rests on the code and the dependency list.
One honest note on timing: this applies from the next Android release (1.1.0, not yet shipped). The build currently on Google Play still declares the permission. I would rather tell you that than overstate it. Once 1.1.0 ships, the Play listing's permission list should show no network access, and you can verify it yourself with aapt dump permissions on the APK.
The same idea exists on the desktop side of the codebase. macos/Runner/Release.entitlements contains only two entries:
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.files.user-selected.read-write</key>
<true/>
The App Sandbox is on, and there is no com.apple.security.network.client or .server entitlement, so a sandboxed release binary cannot reach the network. I mention this as a codebase detail only. macOS is not a shipped product.
From 1.1.0, the main manifest also sets allowBackup="false", fullBackupContent="false" and a data-extraction rules file. The reason is the same as the rest of this post: the database should not be silently copied to a Google account or another device by the OS. Backup is something the owner does on purpose. Until that release ships, the phone's own backup may include app data.
The banned packages, and why
The list of things the repo refuses is short and specific:
-
google_fonts. It downloads font files at runtime. Instead the app bundles JetBrains Mono underassets/fonts/and uses it by name:
static const _fontFamily = 'JetBrainsMono';
The fonts are declared in pubspec.yaml and ship inside the binary. The first launch looks the same as the hundredth, with or without a connection.
-
connectivity_plus. There is nothing to branch on. The app is never "online", so it never needs to ask. Code that checks connectivity is also code that eventually does something different when connected. -
workmanagerfor sync. No background sync, so no background worker. - Firebase, Supabase and similar clients. These are the obvious ones. They also bring analytics and crash reporting along, which are banned for the same reason.
- Analytics, telemetry, crash reporting, remote config, update checkers. None of them are in the app.
You can audit this from pubspec.yaml in a minute. The dependency list is Riverpod, Drift and SQLite, Hive, go_router, ESC/POS printing packages, pdf/printing, image_picker, share_plus, csv, url_launcher, and a handful of utilities. archive is there for zip snapshots and is pure Dart. A dependency list that short is easy to review, and that is part of the point.
The database: Drift on SQLite
Everything lives in a local SQLite file via Drift. Products, orders, customers, inventory, taxes, expenses, returns, tables and an audit log are Drift tables, accessed through DAOs:
daos: [
ProductsDao,
OrdersDao,
CustomersDao,
InventoryDao,
TaxDao,
ExpensesDao,
AuditDao,
TablesDao,
],
With no server, the local schema is the only schema. There is no backend to migrate on your behalf and no way to re-download a user's data if you break it. A bad migration on a shop's device corrupts the only copy of their sales history. So migrations are where I spend the most care.
Migrations use the Migrator, not raw SQL
The database is at schema version 15 as I write this. Each upgrade is an if (from < N) step that goes through Drift's Migrator:
static const int currentSchemaVersion = 15;
onUpgrade: (m, from, to) async {
if (from < 2) {
await m.addColumn(customers, customers.defaultDiscount);
await m.addColumn(customers, customers.defaultDiscountIsPercent);
}
// ...
if (from < 15) {
await m.createIndex(idxOrdersCreatedAt);
await m.createIndex(idxOrdersCustomerId);
await m.createIndex(idxOrderItemsOrderId);
// ...
}
},
The comment in the source explains why: using the Migrator means the DDL is exactly what Drift would generate for a fresh install, including NULL, CHECK and DEFAULT text. Hand-written ALTER TABLE strings drift (pun intended) from that over time.
A test that upgrades every shipped version
The safety net is test/drift/migration_test.dart. Drift can dump the schema at each version to JSON (drift_schemas/) and generate helper code from it. The test starts a database at each version that has shipped, runs the real onUpgrade steps, and checks the result against what the current code expects:
const shipped = [4, 6, 7, 8, 9, 10, 11, 12, 13, 14];
for (final from in shipped) {
test('upgrade v$from → v${AppDatabase.currentSchemaVersion} yields the expected schema',
() async {
final connection = await verifier.startAt(from);
final db = AppDatabase(connection);
addTearDown(db.close);
await verifier.migrateAndValidate(db, AppDatabase.currentSchemaVersion);
});
}
A second test opens a fresh in-memory database, which runs createAll, and validates the live SQLite schema against the generated definitions with dropped-table checking on. If an upgrade path and a fresh install ever disagree, the test fails.
Schema checks are not enough on their own, because a migration can produce the right shape and still lose data. So there are also data-level tests. One seeds a version 11 database with a line item, runs the migration that drops a column, and asserts the item is still there with the right product name, quantity and total. Another seeds version 8 orders and checks that invoice numbers are back-filled.
The workflow for any table change is written down: bump currentSchemaVersion, add the from < N step, run build_runner, dump the schema, generate the test helpers, run flutter test test/drift. It is tedious, and I would still choose it over finding out from a shopkeeper that their orders vanished.
The one network-adjacent path: url_launcher
Some features look like they need a network: emailing a receipt, texting a customer, calling a number. The app does not do any of that itself. It builds a link and hands it to the phone's own apps with url_launcher:
ok = await launchUrl(uri, mode: LaunchMode.externalApplication);
The link builders live in lib/core/utils/link_uris.dart. They produce mailto: (RFC 6068) and sms: URIs. One detail was worth getting right: do not build these with Uri(queryParameters: ...), because that form-encodes a space as +, and mail and message apps do not decode it back. A receipt would arrive as "Total+due+12.50". The helpers percent-encode every value instead, so a space is %20 and a literal + is %2B. (That fix is in the repo for the next release and is test-verified, not yet confirmed on real devices. The current store builds still have the + problem.)
If no app can handle the link, the app copies the text to the clipboard and tells the user. The mail or messaging app does the sending, under its own permissions. openPOS never opens a connection. That is the only category of "network-adjacent" code I allow, and CLAUDE.md names it explicitly. If a future feature genuinely needs network access, the rule is to call it out and get confirmation before wiring it up.
The trade-offs
Being honest about the costs matters more than the pitch.
One device is one register. There is no sync, so two phones running openPOS are two independent shops with two independent databases. If you need several tills sharing one inventory, this is the wrong tool.
No cloud, so no recovery from the cloud. If the device is lost and you never exported anything, the data is gone. Backup is on the owner. Data can be exported as CSV, and the repo has an import path for CSV too, so you can move products, customers, orders and expenses between devices yourself. It is manual by design.
No remote visibility. You cannot check today's sales from home. Reports exist on the device and nowhere else.
Less convenient for me. No crash reporting means I do not learn about bugs unless someone tells me. That is a real cost and I have accepted it. A privacy claim that depends on "except for a little telemetry" is not the claim I want to make.
What is coming
Work on the next release (1.1.0) is in the repo but not in any store build yet, so treat these as upcoming rather than available today: the permission stripping and backup settings described above for Android, stronger backup and restore (streamed snapshots, restore recovery that survives a power cut, receipt photos carried in manual backups), and a few smaller fixes.
It also adds an optional usage summary. No analytics service, no tracking. The summary is built and shown on the device, and it stays there unless the shopkeeper chooses to send it. Sending is a button that hands the text to WhatsApp or the mail app through url_launcher, the same path as receipts, so the app's own code still makes no network calls. The relevant code is under lib/features/usage/, if you want to check that claim yourself rather than take my word for it. This is a deliberate trade: a little feedback from people who choose to give it, instead of telemetry nobody chose.
Try it, read it, help
The code is MIT licensed. If an offline-by-design POS is useful to you, or you just want to read how the manifest, the Drift migrations and the tests fit together:
- Google Play: https://play.google.com/store/apps/details?id=com.brandbuilder.openpos&utm_source=devto&utm_medium=article (the listing is the current build; 1.1.0 is not out yet)
- App Store: https://apps.apple.com/app/open-pos-offline/id6761003751
- Source: https://github.com/onepiece92/openPOS
If it is useful, a star on GitHub helps other people find it. Issues and pull requests are welcome, with one house rule: please read the offline-first section of CLAUDE.md before proposing anything that touches the network.
Disclosure: I'm on the team that builds Open POS. This post was drafted with AI assistance and reviewed against the source code.
Top comments (0)