Toggle Dark/Light/Auto modeToggle Dark/Light/Auto modeToggle Dark/Light/Auto modeBack to homepage
Closure-vs-lambda
• Section: Dart
Bottom line
“Lambda” = anonymous function
“closure” = function with its environment.
In Dart, lambdas are closures, but the terms aren’t synonymous
Lambda
An anonymous function literal, e.g., () { ... } or () => expr.
It’s about syntax (no name).
Closure
A function object that carries its lexical environment (captures variables from surrounding scope).
It’s about behavior.
In Dart
All functions are closures (including top-level, static, named, lambdas, and method tear-offs), but “closure” emphasizes that the function can access surrounding variables.
A lambda may or may not capture anything. If it captures, it’s a capturing closure; if not, it’s a zero-capture closure.