šŸŽÆ Project: Personal Greeting App

šŸ“š Lesson 1: Your First Dart App ā± 15-20 min šŸ“Š Beginner
šŸŽÆ Objective

Build a command-line program that interacts with the user and performs basic calculations using everything you learned in Lesson 1.

Requirements

  1. Create a new Dart file called greeting_app.dart in your project's bin folder
  2. Ask for user's name using stdin.readLineSync() (you'll need to import 'dart:io';)
  3. Ask for their age and convert it to an integer
  4. Calculate approximate birth year using current year minus age
  5. Print a personalized greeting including their name and calculated birth year
  6. Handle invalid input (empty name, non-numeric age, unrealistic ages)
  7. Add a fun message based on their age group (minor, adult, senior)

Expected Output

Terminal
=== Personal Greeting App ===

What is your name?
> Alice

How old are you?
> 25

Hello, Alice! šŸ‘‹
You were born around the year 2001.
You are an adult. Perfect time to learn Dart!
Terminal (Error Handling)
=== Personal Greeting App ===

What is your name?
> 

Error: Name cannot be empty. Please try again.

Step-by-Step Hints

šŸ’” Hint 1: Getting Started

Start with import 'dart:io'; at the top. This gives you access to stdin.readLineSync() for reading user input.

šŸ’” Hint 2: Safe Number Conversion

Use int.tryParse(input) instead of int.parse(input). tryParse returns null if the conversion fails instead of throwing an error.

šŸ’” Hint 3: Getting Current Year

Use DateTime.now().year to get the current year dynamically.

Challenge: Extend the Project

Once you've completed the basic requirements, try these extensions:

  1. Ask for the user's birth month and calculate a more accurate age
  2. Calculate how many days until their next birthday
  3. Store multiple users' information and display all at the end
  4. Add color to the output using ANSI escape codes
šŸŽ‰ Well Done!

You've completed your first Dart project! This demonstrates understanding of variables, user input, type conversion, conditional logic, and string interpolation - all fundamental Dart concepts.