Stage 1 · Lesson 1 of 10
var, final, const and type inference
works out types for you, so var count = 3 is an int and can never hold a string later. Use a value when it is set once while the app runs. Use a const value when it is known before the app even runs; Dart creates it once and shares it.
uses const to skip rebuilding them. Default to final, and use var only when you reassign. Learn the core types: int, double, String, bool, and dynamic, which turns checking off and which you should avoid.
Learn too, as in 'Hello $name'. Keep in mind that final fixes only the reference, which matters later when you manage state.
Common trapthinking final makes an object frozen: final items = [1, 2] still lets you call items.add(3).
A question to check yourself, an AI practice session and 1 cheat sheet entry come with the full roadmap. Unlock
Resources for this stage
Start with
- GuideFreeDart Language Tour
Google · Beginner
The official tour: read it in order and rerun every example in DartPad