Dart Foundations in Dart

Dart Foundations is where you start writing Dart.

In this chapter, you will:

  • learn what Dart is, where it runs, and how to run your first program
  • store values in variables, and choose between var, final and const
  • learn the main data types: int, double, String and bool
  • convert text into numbers, and numbers into text, safely

What each lesson covers:

  • Introduction to Dart: What Dart is, why Google made it, how it works with Flutter, where it is used, how to set it up, and how to write your first program with comments.
  • Variables and Constants: How to store values in variables, the rules for naming them, and when to use var, final and const.
  • Data Types: The basic Dart types (int, double, num, String, bool, dynamic, Object, Null, Never), how Dart infers types, and how to check, convert, parse and cast values.

This chapter has 3 lessons. Plan on about 57 minutes, with 12 exercises to check what you learned. Every example is real Dart code: change it, run it again and compare the output, which is the fastest way to learn how each feature behaves.

Simple lesson: finish this chapter and you can write small Dart programs that remember and print values.

Lessons in this section

  1. Introduction to Dart

    What Dart is, why Google made it, how it works with Flutter, where it is used, how to set it up, and how to write your first program with comments.

    • Explain what Dart is and how it relates to Flutter
    • Name the four places where Dart programs run
    • Install Dart, check the version, create and run a project
    • Write a program with main(), statements and a code block
  2. Variables and Constants

    How to store values in variables, the rules for naming them, and when to use var, final and const.

    • Create, assign and reassign variables
    • Follow Dart's naming rules and conventions
    • Choose between var, final and const
  3. Data Types

    The basic Dart types (int, double, num, String, bool, dynamic, Object, Null, Never), how Dart infers types, and how to check, convert, parse and cast values.

    • Choose the right type for a value
    • Use type inference and check types at runtime
    • Convert between text and numbers safely, and cast with is and as