FlutterDartDriftSQLiteProviderOCRML Kit

Receipt Splitter

A Flutter application for scanning receipts, splitting expenses between people, and keeping track of who still needs to pay.

Receipt Splitter dashboard showing open settlements and bill summaries

The Problem

Splitting a receipt gets more complicated when people pay for different items or only pay back part of what they owe. I wanted to build an application that helps enter receipt items and keeps track of the expenses, who paid, and what everyone still owes.

  • Entering every receipt item by hand takes time.
  • Different people can pay for different expenses.
  • Each expense may need to be split between a different group of people.
  • Bills and payments need to remain available after closing the application.

The Solution

Receipt Splitter lets users scan a receipt or select an image from their gallery. The application reads the text and turns detected items into an editable bill draft. Users can then add participants, assign who paid, and split each expense. Once the bill is finalized, the application tracks the remaining payments. All data is stored locally on the device.

  • Capture a receipt with the camera or select one from the gallery.
  • Crop the image before text recognition.
  • Turn detected receipt items into expenses that can be reviewed and edited.
  • Assign payers and split expenses between selected participants.
  • Keep track of draft, open, and settled bills.
  • View outstanding amounts and who still owes money from the dashboard.

Architecture

How It Works

The Flutter screens use Provider-backed ViewModels to manage state and user actions. A repository handles storage through Drift and SQLite, with mappers converting database rows into models used by the application. Receipt scanning follows a separate flow. The user selects or captures an image, crops it, and runs it through ML Kit text recognition. A parser turns the recognized text into receipt items, which are saved as draft expenses for review.

Flutter UIProvider ViewModelsDrift RepositorySQLite PersistenceOCR PipelineReceipt Parsing
receipt_parser.dart
static List<ReceiptItem> parse(String rawText) {
  final lines = rawText
      .split('\n')
      .map(_normalizeLine)
      .where((line) => line.isNotEmpty)
      .toList();

  final separatedItems = _parseSeparatedItemsAndPrices(lines);
  if (separatedItems.isNotEmpty) {
    return separatedItems;
  }

  final inlineItems = _parseInlineItems(lines);
  return inlineItems;
}

Screenshots

Dashboard showing outstanding payments, recent drafts, and bill summaries
Bills overview organized into draft, open, and settled categories
Bill draft with participants and imported expenses ready for review
Bill details showing participants, expenses, payers, and outstanding amounts
Overview of each participant's outstanding balance across bills

Technical Decisions

Turning Scanned Text Into Expenses

ML Kit handles text recognition, and a separate parser turns that text into receipt items. The items become draft expenses so users can review and correct them before finalizing the bill.

Storing Everything Locally

I used Drift and SQLite to store bills, people, participants, expenses, and splits on the device. This lets the application work without a backend while keeping relationships between the data explicit.

Separating Database Access

A BillRepository handles database access, while mapper classes convert Drift rows into application models. This keeps database-specific code out of the screens.

Managing Screen State With ViewModels

Provider-backed ViewModels handle screen state, subscriptions, validation, and user actions. Widgets display that state and pass actions to the ViewModel, keeping bill and payment logic outside the UI.

Calculating Summaries From Existing Data

Dashboard totals and outstanding balances are calculated from bills, expenses, and splits. Keeping these values calculated avoids storing separate totals that also need to be updated after every change.

Checking Bills Before Finalization

Bills start as drafts. Before a bill can be opened, each expense needs a payer and valid splits. The bill becomes settled once all splits are fully paid.

From Receipt Scan To Settled Bill

The main challenge was connecting receipt scanning to the rest of the application. Recognized text can contain mistakes, so users need to be able to correct the imported items. Those items then need payers, participants, and valid splits before the bill can be finalized. Partial payments also affect the remaining balances and settlement status. Keeping parsing, validation, and payment calculations separate helped make this flow easier to manage.

What I Learned

Structuring A Flutter Application

I used separate screens, widgets, ViewModels, services, and repositories to keep UI code apart from storage and payment logic.

Modeling Related Data

Bills, people, participants, expenses, and splits each have their own role in the database. Working out those relationships was an important part of supporting different payers and partial payments.

Working With OCR Output

Text recognition is only one part of scanning a receipt. I also needed to parse the output into useful items and give users a way to correct the result before using it in a bill.

Keeping Balances And Statuses Consistent

Payments affect individual splits, participant balances, bill status, and dashboard summaries. Calculating these values from the underlying expense and payment data helped keep them consistent.

Damien Hensen

A Bit About Me

Outside of software development, I enjoy gaming, anime, and working on personal projects that help me learn something new.

Whether it's building applications, automating workflows, or experimenting with new technologies, I enjoy creating things and understanding how they work.

Let's connect.