Dart Essentials

The Dart language behind Flutter: sound null safety, classes, collections, and async with Futures and Streams.

Beginner · about 10 hours · difficulty 2/5

If you chose Flutter, Dart is your daily language. It will feel familiar if you know Java, Kotlin, TypeScript or C#.

What to learn

  • Variables: var, final (set once) and const (compile-time constant). Use const widgets where possible; Flutter can skip rebuilding them.
  • Sound null safety: String can never be null, String? can. Use ?., ?? and ! (sparingly).
  • Functions: named parameters with required, optional positional parameters, arrow syntax.
  • Classes: constructors, named constructors, factory, mixins and extension methods.
  • Collections: List, Map, Set, collection if and for inside literals, spread ....
  • Records and patterns (Dart 3) for returning multiple values and destructuring.

Async

Future<T> represents one later value and pairs with async/await. Stream<T> represents many values over time, used for things like auth state or database changes.

Pitfalls

Overusing the ! operator turns null safety back into runtime crashes. Model optional data honestly.

Good enough to move on: you can write a class with a named constructor, parse a JSON map into it, and fetch data with await.

Key concepts

  • var, final and const
  • Sound null safety
  • Named and required parameters
  • Classes, constructors and mixins
  • Collections and collection if/for
  • Futures and async/await
  • Streams
  • Records and patterns

Mini project

In DartPad, model a Todo class with fromJson/toJson, parse a JSON list of todos, and print only the incomplete ones.

Check yourself

What is the difference between final and const in Dart, and why does it matter for Flutter widgets?

Free resources