Dart Tutorial

Dart Chapter 2 of 15

Dart Basics

Variables, data types, numbers, strings, booleans, operators and reading input: the building blocks of every Dart program.

These lessons cover the vocabulary of the language. Almost every line of Dart you will ever write uses something from this chapter, so take your time and run the examples.

Lessons in this chapter

  1. Variables in Dart: var, Explicit Types and dynamicLearn how to declare variables in Dart with var and explicit types, how type inference works, and the rules for naming them.
  2. Data Types in Dart: A Complete OverviewA tour of Dart's built-in data types: int, double, String, bool, List, Set, Map, Record, Null, Object and dynamic, with examples.
  3. Numbers in Dart: int, double and numWork with int, double and num in Dart: arithmetic, integer division, rounding, parsing text into numbers and the dart:math library.
  4. Strings in Dart: Interpolation, Methods and Multi-Line TextCreate and work with strings in Dart: quotes, interpolation, multi-line and raw strings, common methods, and StringBuffer.
  5. Booleans in Dart: true, false and Logical OperatorsUnderstand the bool type in Dart, comparison results, and how to combine conditions with the and, or and not operators.
  6. Operators in Dart: Arithmetic, Comparison, Logical and MoreEvery operator in Dart explained with examples: arithmetic, assignment, comparison, logical, type test, cascade and null-aware.
  7. final vs const in Dart: Values That Do Not ChangeLearn the difference between final and const in Dart, when each is set, and why constant values make code safer and faster.
  8. Type Conversion in Dart: Converting Between TypesConvert between String, int, double, bool and collections in Dart using parse, tryParse, toString, toInt and friends.
  9. Reading User Input in Dart with stdinRead text and numbers typed by the user in a Dart console program using stdin.readLineSync, with safe parsing and validation.