Skip to content

Lab · Flutter and Dart

Lab: a chai stall's day in Dart

Labbeginner· about 1.5 hours· 4 steps

The brief

Write one small Dart program for Sharma Chai Stall: the day's cup count and sales, the menu in a Map, a week's report with a switch expression, and an office order bill with GST worked out by your own functions.

Why it matters

Every Flutter screen is built from this plain Dart: values in variables, lists of items, loops and decisions, and small functions such as a price formatter that every screen calls. Shop, canteen and delivery apps all start with exactly these sums.

Skills you practise

  • const, final and var
  • int, String and interpolation
  • int.parse and int.tryParse
  • List, Map and Set
  • where, map and fold
  • for loops, if/else and switch expressions
  • collection if and for
  • named parameters and functions as values

You need

  • A web browser with DartPad (dartpad.dev), or the Dart SDK 3.5 or newer (it comes with Flutter) to run dart run chai_day.dart

What you will have at the end

chai_day.dart: one Dart program that prints a chai stall's day, menu, weekly report and an office bill with GST, using variables, collections, control flow and functions.

How it is marked (rubric, 100 points)
Correct resultsEvery printed number matches: 60 cups, Rs 900, Rs 113, 595 cups, Rs 169.05, and the bulk list.50
Right Dart for the jobconst and final where values do not change, a Map for the menu, a Set for unique kinds, a switch expression, collection if/for, and ~/ instead of /.25
Clean functionsSmall functions with return types and named parameters with defaults; money kept in int paise.15
ExplainedYou can say what int.tryParse returns for bad text and why the paise need padLeft.10

0/4 steps done

Step 1 of 4

Count the day's cups and sales

partOne prints the shop name, the cups sold in the morning and evening, the total, and the sales in rupees.

Make the shop name and the chai price const: they are known while you write the code. The morning count (48) is a final. The evening count arrives as text on a paper slip, so turn '12' into a number with int.parse. A slip that says 'twelve' cannot be read: int.tryParse gives null instead of crashing, so print what it returns.

Then print the total cups, the cups per hour over a 12-hour day with ~/ (integer division), and the sales: total cups times the price. Use $name and ${expression} inside the strings, exactly as in the expected lines.

Run this on your machine, then paste the output below
$ dart run chai_day.dart (or press Run in DartPad and copy the Console)

Also check yourself

Your notes: chai_day.dart

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