0PricingLogin
Dart Academy · Lesson

Anonymous Functions and Closures

Capture variables in inline functions.

Functions Without Names

Sometimes you need a function once and never again. An anonymous function has no name and is written right where you use it. ✨

The Basic Shape

An anonymous function is just parameters and a body, with no name in front. You can store it in a variable.

var greet = (String n) {
  print('Hi ' + n);
};

All lessons in this course

  1. Arrow Syntax for One-Line Functions
  2. Anonymous Functions and Closures
  3. Nullable Types and the Question Mark
  4. Null-Aware Operators: ?., ??, and !
← Back to Dart Academy