Four shopkeeping jobs run by themselves
This is not only a shop front. The bookkeeping that a shopkeeper normally does by hand is done in code:
- Stock follows every sale. When a customer places an order the ordered quantities are posted to your catalogue sheet, and when a counter bill is saved only the difference is posted — so a corrected bill is adjusted, not double-counted. Deleting a bill posts its quantities back. This one needs the Apps Script in section 7 connected; the other three need nothing but Firebase.
- The credit ledger totals itself. A customer's outstanding balance is the credit entered minus the payments recorded — recomputed from the records, never stored as a hand-typed figure. The whole ledger can be handed to a customer as a WhatsApp or SMS draft in one tap.
- The trading day closes itself. Counter bills are numbered in a sequence that restarts each day, and the reports screen turns orders, bills and payments into today / last 7 days / this month / all-time summaries with the best-selling items. The inventory screen builds the reorder list from the low-stock flags.
- Your Google Sheet stays the single source. The same sheet the catalogue is read from is the sheet stock is written back to — prices, quantities and new items never live in two places.
Stated plainly so nobody is surprised: stock is not returned when an online order is cancelled (only deleting a counter bill restores it), the app sends no push notifications, and it takes no scheduled cloud backup.
1. What you received
| Path | What it is |
|---|---|
lib/ | The complete Flutter source — no obfuscation, no compiled blobs. |
lib/core/config/store_config.dart | The only file you must edit. Shop name, numbers, address, hours, delivery charge, sheet links. |
firestore.rules | Ready-made Firestore security rules for every collection the app uses. |
apps_script/StorePOSInventorySync.gs | The stock write-back endpoint — paste it into Apps Script, fill four config values, and quantities follow your sales. |
assets/data/sample_products.csv | 317-item sample catalogue showing the sheet format. |
assets/images/products/ | Bundled product photography used by the sample catalogue. |
test/ | 466 automated tests. flutter test should end with “All tests passed!”. |
android/ ios/ web/ … | Platform folders, already renamed to storepos / com.storepos.app. |
You will need your own Firebase project and, if you want cloud storage for orders, your own Google Sheet. Both have free tiers.
2. Run it in five minutes (no Firebase needed)
Preview mode exists so you can look at the whole product before wiring anything up. It opens the shop front and the owner panel with no login, no server and no internet, using the bundled sample catalogue and a handful of sample orders. Nothing is saved anywhere.
flutter pub get
flutter run --dart-define=preview-mode=true
In a browser instead:
flutter build web --release --no-web-resources-cdn --dart-define=preview-mode=true
Running without the flag expects a real Firebase project; if you have not done section 6 yet, the app will fail at start-up. That is the intended behaviour of a production build.
3. Make it your shop's
3.1 The config file
Open lib/core/config/store_config.dart. Every field is commented in
the file. The important ones:
| Field | Where it appears |
|---|---|
storeName / storeNameLocal | App bar, splash, receipts, WhatsApp message text, admin summaries. The second one is the name in the customer's own script; leave it '' to hide. |
storeKind / storeKindLocal | The small line under the name. |
ownerPhone, ownerPhone2 | Call and WhatsApp buttons, store-info card, receipt footer. |
paymentHolder | The name shown on the EasyPaisa / JazzCash line at checkout. |
address, hours, storeLat, storeLng | Store-info card. A pin of 0, 0 hides “Open in Maps”. |
deliveryCharge | Checkout total and the delivery strip under the header. |
productsSheetCsvUrl, inventorySheetUrl, stockScriptUrl | Optional Google Sheet links (section 4 and 7). |
No shop name, phone number or address exists anywhere else in lib/ —
change the file, rebuild, and receipts, messages and admin screens all follow.
3.2 Logo, icon and app name
- Replace
assets/images/store_icon.pngwith your own square logo (512×512 looks sharp everywhere). - For the launcher icon, drop a 1024×1024 PNG at
assets/images/store_icon_master_1024.pngand rundart run flutter_launcher_icons. - Set the name under the icon:
android:labelinandroid/app/src/main/AndroidManifest.xml, and thenamefields inweb/manifest.json. - Give your build its own identity:
applicationIdandnamespaceinandroid/app/build.gradle.kts, and the bundle identifier in Xcode for iOS.
4. Products: a Google Sheet, or the bundled file
4.1 With a sheet (recommended for a live shop)
Create one Google Sheet with five columns in this order and publish it as CSV
(File → Share → Publish to the web → CSV). Put the resulting URL in
productsSheetCsvUrl.
| Column | Example | Notes |
|---|---|---|
Item | Cooking Oil 1L | Exact name is used for photo matching. A pack size written in the name (1kg, 5L, 180ml, 20 کلو) is split off and shown separately. |
Price | 600 | Plain number; Rs and thousands separators are tolerated. |
Stock | 36 bottle | Free text. The first number in it decides the low-stock flag: 3 or fewer shows “needs reorder”. |
Status | in stock | out of stock (or ختم) sells nothing and greys the card. |
Image | empty | Optional direct image URL, used only when the app has no bundled photo for that item. |
Row 1 is the header and is ignored. assets/data/sample_products.csv
is a working example — open it and copy the shape. Its prices are placeholder
numbers, not a price list.
4.2 Without a sheet
Leave productsSheetCsvUrl empty and the app serves the bundled
sample catalogue. That is fine for a demo; for a real shop either fill in a sheet
or replace assets/data/sample_products.csv with your own list in the
same five-column format.
4.3 Product photos
Bundled photos are matched to item names in
lib/core/constants/product_photos.dart:
'Cooking Oil 1L': 'assets/images/products/10.jpg',
To add one: put the picture in assets/images/products/, add a line
to that map with the exact Item name, and rebuild. The folder is
already declared in pubspec.yaml. An item with no photo shows a clean
neutral icon instead — never a wrong picture.
5. Categories
The sheet has no category column; the app derives one from the item name using
keyword rules in lib/core/i18n/product_taxonomy.dart. Ten categories
ship by default (grocery, tea & milk, drinks, biscuits & snacks, cleaning,
personal care, electronics, stationery, cigarettes & pan, miscellaneous), each
with its own icon and English / Urdu label.
To move an item into a different category, add its keyword to that category's word list. Order matters: personal care and electronics are checked before grocery, because words like “oil” and “cleaning” appear in both.
6. Firebase (accounts, orders, bills, ledgers)
Skip this section entirely if you only want the preview or a single-device shop. Everything below is free on the Firebase Blaze / Spark plans.
- Create a project at
console.firebase.google.com. - Add an Android app (and an iOS app if needed). Use the same application ID you set in section 3.2.
- Install the CLI once:
dart pub global activate flutterfire_cli - From the project folder run:
flutterfire configure— it writeslib/firebase_options.dartand the platform config files. - In the console enable Authentication → Sign-in method (email / password, phone, or Google — whichever you want customers to use).
- Create a Cloud Firestore database.
- Open Firestore Database → Rules, paste the contents of the
included
firestore.rules, and press Publish. - Register one customer account in the app (any email you control). Then in the Firebase console open Authentication → Users, click that user and copy the UID.
- In Firestore, create a collection called
adminsand add a document whose document ID is that UID. Only then does the owner panel appear — there is no self-service way to become an admin.
Collections used: admins, orders,
addresses, ratings, age_verifications,
shop_bills, bill_payments. They are created
automatically the first time the app writes to them.
android/app/google-services.json is a credential file. It is
git-ignored in this project — keep it out of any public repository.
7. Writing stock back to the sheet (the automation switch)
Reading the catalogue from a sheet needs nothing from you. The automation that
makes this app more than a shop front — quantities dropping as orders and counter
bills come in — runs through one Google Apps Script web app standing in front of
the sheet. The script is included:
apps_script/StorePOSInventorySync.gs. Copy it into a new Apps Script
project, fill the four values in its CONFIG block, deploy it as a web
app, and paste the deployment URL into stockScriptUrl.
The app sends a JSON body with Content-Type: text/plain (deliberate:
it avoids the CORS preflight that Apps Script often fails) and expects a JSON
reply of { "ok": true }. The included script answers all four:
| Action | Body the app sends | When |
|---|---|---|
updateItem | {action, token, name, price, stock, status} | Owner edits an item in the inventory screen. |
addItem | {action, token, name, price, stock} | Owner adds a new item from the app. |
restoreStock | {action, items:[{name, quantity}]} | A counter bill is deleted, so its quantities go back. |
| no action | {items:[{name, quantity}]} | A customer places an order, or a counter bill is saved or edited. |
Item names are matched against the Item column, case and spacing
ignored, and a unit tail such as "40 بوری" is preserved when the number changes.
updateItem and addItem carry the signed-in owner's
Firebase ID token; the included script verifies it server-side and, if you list
uids in an Admins tab, checks the caller is one of them. The
order-time calls have no token — a customer checking out is not an owner — so keep
the deployment URL private. Stock updates are best-effort by design: if the script
is unreachable the order still goes through and the app never blocks on it.
8. Running the shop
8.1 Orders
An order moves through Processing → Confirmed → Delivered, or is cancelled. The owner panel opens on the live list with counts per status, today's total and a search box that accepts an order number, a phone number or an email. Changing a status is one tap on the order card. “Receipts pending” collects the deliveries whose receipt has not been sent yet.
8.2 Receipts
Each order can be sent to the customer as a formatted text receipt through WhatsApp or SMS, with the item lines, delivery charge and total.
8.3 Counter bills (POS)
For walk-in sales: open Shop bill, tap items to add them, adjust quantities, apply a discount, mark the payment as cash, and create the bill. The customer can be sent an itemised bill by SMS.
8.4 Credit ledger (khata)
Give a regular customer a credit line, record what they owe, and log part payments against it. Each ledger has a statement link that opens a pre-written SMS on the owner's phone, so a reminder is one tap away.
8.5 Inventory, reports and ratings
The inventory screen lists every item with its stock note and flags low stock; “needs reorder” filters to what has to be bought in, and a supplier list can be generated from it. Reports show today, last 7 days, this month and all-time figures, a daily bar chart, and the best-selling items. Ratings shows the average and each order's stars.
9. Building for Android, iOS and web
# one APK covering all densities — good for testing on a phone
flutter build apk --release
# Play Store upload
flutter build appbundle --release
# iPhone (macOS with Xcode required)
flutter build ios --release
# website build, served from build/web
flutter build web --release
Release signing reads android/key.properties when that file exists
and falls back to debug signing when it does not, so a release build works on day
one before you have created a keystore. For a Play Store upload, create your own
keystore and add:
storeFile=../keystore.jks
storePassword=...
keyPassword=...
keyAlias=...
Never commit a keystore or its passwords.
10. Customising further
| To change | Edit |
|---|---|
| Every label in both languages | lib/core/i18n/strings.dart — one getter per label, en ? … : …. |
| Colours, radius, gradients | lib/core/theme/app_theme.dart (navy and gold by default). |
| Category names and keywords | lib/core/i18n/product_taxonomy.dart, icons in lib/core/constants/category_icons.dart. |
| Search synonyms | lib/core/i18n/search_terms.dart — romanised spellings that should find a local item name. |
| Receipt / message wording | lib/services/receipt_formatter.dart and lib/services/store_contact.dart. |
| Add a language | Copy the pattern in strings.dart; the layout already flips to right-to-left for Urdu. |
After any change, run flutter analyze and flutter test —
the suite covers receipts, order status notices, ratings, ledgers and the
catalogue parser.
11. Troubleshooting
| symptom | cause and fix |
|---|---|
| App closes at start-up with a Firebase error | You ran it without --dart-define=preview-mode=true and have not done section 6 yet. |
| Shop is empty | Sheet URL is wrong or not published as CSV. File → Share → Publish to the web → CSV, then paste that URL. Row 1 must be the header. |
| Prices show as Rs 0 | The price cell contains text the parser could not read. Keep it a plain number. |
| Owner panel shows “could not be reached” | Rules not published, or your uid is not in the admins collection. |
| Order placed but nothing appears in the panel | Firestore is offline on the phone, or the order went to a different project — check lib/firebase_options.dart. |
| Stock does not change in the sheet | Expected: write-back needs the Apps Script in section 7. Without it the sheet is read-only. |
| Photos missing for new items | Add the file to assets/images/products/ and one line to product_photos.dart with the exact item name. |
| “Low stock” appears wrongly | The stock column's first number is what counts. Write “12 box”, not “a few”. |
12. Support and licence
What support covers
- Bugs in the delivered code — something that does not work as this guide describes.
- Help getting the item to compile, run and connect to your own Firebase project.
- Clarification of anything written here.
What it does not cover
- Adapting the included sheet endpoint to a sheet that is laid out differently, designing your sheet, or running your business.
- New features, screens, languages or integrations.
- Third-party services changing their own behaviour (a Google Sheet or Firebase outage, a Play Store policy change).
- Building the app for a client on your behalf.
How to ask
Use the comments tab on the item page, or the marketplace messaging system.
Please include: your Flutter version (flutter --version), the exact
error text, what you expected, and whether you are running in preview mode. A
screenshot or a short screen recording resolves most reports without a second
round of questions.
Typical first reply: within two working days.
Licence
One licence covers one end product for one shop. The Extended licence is required when the app is used in something you charge for, or when an agency delivers it to a client. You may modify the source freely for your own licensed product. Redistribution or resale of the source itself is not permitted. Full terms: codecanyon.net/licenses.