testsAndMisc-archive/billsplit
Krzysztof Rudnicki 5c52de0682 billsplit: build a real APK by dropping file_picker for file_selector
billsplit had never produced an Android APK. file_picker 11.0.3 — the latest
release on pub.dev — is wedged under AGP 9 in both directions: it skips
applying the Kotlin Gradle Plugin when AGP >= 9, so with built-in Kotlin off
its own Kotlin never compiles (`cannot find symbol: FilePickerPlugin`), and
with built-in Kotlin on its buildscript leaks KGP onto the global classpath
via rootProject.allprojects, which AGP then rejects for every module.

The app's Gradle config was never at fault: android/app/build.gradle.kts and
settings.gradle.kts are byte-identical to habit_stack, home_inventory and
diet_guard_app, which all build. Only the dependency differed, so the fix is
the dependency — the toolchain stays on the house-standard AGP 9.

Ported both call sites to the official file_selector. Its save flow returns a
destination and leaves the write to the caller, where file_picker wrote the
bytes inside the plugin; that write now goes through an injectable seam
because a real dart:io future never completes inside testWidgets' fake-async
zone, so a widget test could otherwise never observe the resulting snackbar.
The test double moves from a MethodChannel mock to a FileSelectorPlatform fake
(file_selector speaks Pigeon, so a channel mock would not intercept it), and a
plain non-widget test covers the real on-disk writer to hold 100% coverage
without an ignore.

The launcher icon is now verified from the built artifact: the ic_launcher
assets unzipped from the APK render as the charcoal + gold perforated receipt,
not the stock Flutter beach. Peak build footprint is 1.86 GiB, inside budget.

Also rewrites ci_mirror.sh to run its gates in a disposable worktree at HEAD.
`pre-commit run --all-files` stashes the live tree, and in a shared checkout
that made an unrelated agent's uncommitted work collide with hook auto-fixes,
failing the push while blaming an innocent hook — and putting that work inside
a stash window, which memories/git-rules.md forbids. A clean worktree needs no
stash and is a truer mirror of CI, which never sees a dirty file.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-03 14:15:40 +02:00
..
android Format last three markdown files; cap billsplit's Android build memory 2026-08-03 13:25:48 +02:00
assets/icon Move billsplit Flutter app into the monorepo 2026-08-03 12:22:22 +02:00
ios Move billsplit Flutter app into the monorepo 2026-08-03 12:22:22 +02:00
lib billsplit: build a real APK by dropping file_picker for file_selector 2026-08-03 14:15:40 +02:00
linux billsplit: build a real APK by dropping file_picker for file_selector 2026-08-03 14:15:40 +02:00
macos billsplit: build a real APK by dropping file_picker for file_selector 2026-08-03 14:15:40 +02:00
test billsplit: build a real APK by dropping file_picker for file_selector 2026-08-03 14:15:40 +02:00
windows billsplit: build a real APK by dropping file_picker for file_selector 2026-08-03 14:15:40 +02:00
.gitignore Move billsplit Flutter app into the monorepo 2026-08-03 12:22:22 +02:00
.metadata Move billsplit Flutter app into the monorepo 2026-08-03 12:22:22 +02:00
analysis_options.yaml Move billsplit Flutter app into the monorepo 2026-08-03 12:22:22 +02:00
pubspec.lock billsplit: build a real APK by dropping file_picker for file_selector 2026-08-03 14:15:40 +02:00
pubspec.yaml billsplit: build a real APK by dropping file_picker for file_selector 2026-08-03 14:15:40 +02:00
README.md Move billsplit Flutter app into the monorepo 2026-08-03 12:22:22 +02:00

BillSplit

Flutter app (mobile + desktop) for splitting shop receipts between people — including the drinkers vs non-drinkers case — with Biedronka e-paragon import and .xlsx export.

Features

  • People roster with a per-person drinks alcohol toggle, plus arbitrary groups (tags) like "meat eaters".
  • Receipts: import a Polish fiscal e-receipt JSON (e-paragon, JPK_KASA_PARAGON_v2-0 — the file the Biedronka app exports; the embedded JWS payload is decoded, signature not verified) or build one manually. Multiple receipts persist locally (state.json in app documents).
  • Per-item assignment: each item is split among Everyone / Drinkers / Non-drinkers / a group / hand-picked people. Alcohol is auto-detected on import (wódka/piwo/wino/… keywords) and defaults to drinkers only; deposits (kaucja) become their own line split among everyone. Category and assignment are always editable — the keyword detection is a default, not a decision.
  • Grosz-exact math: every item's shares sum to exactly the item total (largest-remainder distribution), so per-person totals reconcile with the receipt to the grosz — no floating point drift.
  • Totals view: per person, with alcohol / rest breakdown, unassigned-item warnings, and a reconciliation check against the paid amount.
  • Export .xlsx: one row per item with a 1/0 person matrix plus a summary — same layout as the hand-made spreadsheet this app grew out of. Matrix and summary are exported values (the app is the calculator); column totals are live SUM formulas.

Running

The repo ships lib/, test/, and pubspec.yaml without platform runner folders. Generate them once for the platforms you want:

cd billsplit
flutter create . --platforms=linux,windows,macos,android,ios
flutter pub get
flutter run          # picks a connected device / desktop

Tested with Flutter 3.44.8 / Dart 3.10.

Tests

flutter test

Covers: parsing the real sample receipt in test/fixtures/ (49 items + deposit, totals 590.55 + 7.00 = 597.55 zł), split invariants incl. a 500-case fuzz of the remainder distribution, assignment-mode resolution, and xlsx generation (the test writes build/test_export.xlsx for external inspection).

Design notes / edge cases

  • Money is int grosze end to end; formatting happens only at the UI edge.
  • An item resolving to zero people (e.g. "non-drinkers" on an all-drinker receipt) is excluded from totals and loudly flagged, never silently dropped into someone's bill.
  • Deleting a person prunes them from groups, receipt participants and custom assignments; deleting a group falls back affected items to Everyone.
  • Assignment modes are stored symbolically (not as materialized ID sets), so adding a person later automatically includes them in Everyone items. Touching a person checkbox materializes the current set and switches the item to custom.
  • paidTotalGr (what the card was charged) is kept separately from the item sum; a mismatch shows red in Totals instead of being "fixed" silently.

Quality gates (enforced in CI)

  • dart format --set-exit-if-changed . — formatting is canonical
  • flutter analyze --fatal-infos — very_good_analysis + strict-casts, strict-inference, strict-raw-types; any info fails the build
  • flutter test --coverage + tool/coverage_check.py — 100% line coverage of lib/ is mandatory; the gate also fails if a lib file is never executed by any test