Skip to content

Project · Flutter and Dart

Project: a kirana GST bill in Dart

Projectbeginner· about 5 hours· 6 steps

The brief

Build a Dart console program that a small wholesaler could use to bill kirana shops: a catalogue with optional HSN codes, a bill with CGST and SGST, a price list read from text that skips bad lines, a pretend UPI payment that can be declined, and unit tests that prove the sums.

Why it matters

Billing logic sits behind every shop, distributor and delivery app, and getting a rupee wrong is not acceptable. Keeping it in plain Dart in lib/, away from the screens, means the same code can later power a Flutter app, and dart test can check it on every change.

Skills you practise

  • dart create, dart pub add and dart run
  • classes with const constructors and getters
  • nullable fields and ??
  • money in int paise
  • records and destructuring
  • int.tryParse and double.tryParse
  • sealed classes and switch expressions
  • async/await with Future.delayed
  • dart test and dart analyze

You need

  • The Dart SDK 3.5 or newer (it comes with Flutter 3.24 or newer)
  • VS Code with the Dart extension, or Android Studio
  • A terminal and an internet connection for dart pub add

What you will have at the end

The kirana_bill Dart project: a catalogue, a GST bill with CGST and SGST, a forgiving price-list reader, a pretend UPI payment and at least 8 passing tests, with dart analyze clean.

How it is marked (rubric, 100 points)
Correct sumsSubtotal ₹2,020.00, CGST and SGST ₹99.50 each, grand total ₹2,219.00, exact paise for ₹140.50, and the ₹1,00,000 limit enforced.35
Sound Dart designMoney in int paise, a nullable HSN with ?? at the edge, a record for the GST split, a sealed class with an exhaustive switch, logic in lib/ and printing in bin/.30
Robust inputBad price-list lines are skipped with tryParse and listed, never crashing the program.15
Tested and cleanAt least 8 passing tests, one of them your own, and dart analyze reports no issues.20

0/6 steps done

Step 1 of 6

Create the project

A console project kirana_bill exists on Dart 3.5 or newer, with intl added.

Check your Dart version first: records, patterns and sealed classes need Dart 3, and this course uses 3.5 or newer. Then create the console project and add intl for rupee formatting.

The template puts logic in lib/kirana_bill.dart, the program in bin/kirana_bill.dart and a test in test/. Replace all three with this project's starter files. The template's calculate() function and its test go away.

Run this on your machine, then paste the output below
$ dart --version; dart create -t console kirana_bill

Also check yourself

Your notes: lib/kirana_bill.dart, bin/kirana_bill.dart, test/kirana_bill_test.dart

Write down each command you ran. It goes into your project summary.