Beginner Projects
Prerequisites: Level 1 — Beginner
Build these with nothing but what Level 1 covered — print,
stdin.readLineSync, variables, null safety, conditionals, loops,
collections, and functions. Each one fits in a single .dart file with a
main function.
1. Command-Line Calculator
Read two numbers and an operator (+ - * /) with stdin.readLineSync()
(from dart:io), convert them with double.tryParse, and compute the
result with a switch expression. Print clear messages for invalid
numbers, an unknown operator, or division by zero.
Hint: double.tryParse('abc') returns null — handle it with ?? or
an if (x == null) check.
2. Number Guessing Game
Pick a secret number with Random().nextInt(100) + 1 (from dart:math),
then loop, reading guesses and printing "Too high" or "Too low" until the
player gets it right. Count and print the attempts.
3. To-Do List
Keep tasks in a List<({String title, bool done})> — a list of records.
Loop over a menu (add / list / done / quit) handled with switch, and
print numbered tasks with [x] or [ ] markers.
4. Unit Converter
Store conversion factors in a map ({'km→mi': 0.621371, ...}), list the
options, and convert the number the user enters. Format results with
value.toStringAsFixed(2).
5. Password Generator
Ask for a length, then build a password from a pool of letters, digits,
and symbols using Random.secure(). Refuse lengths under 8.
6. Simple Quiz
Store questions and answers in a list of records, ask each one, compare
answers ignoring case with toLowerCase(), and print a final score like
You scored 4/5.
7. Word Frequency Counter
Split a paragraph into lowercase words, count them in a Map<String, int>
with update(word, (n) => n + 1, ifAbsent: () => 1), and print the five
most common words.