Anonymous and Nested Function

Get introduced to anonymous and nested functions in Dart and learn their syntax.

Function literals

Literals are defined as fixed values appearing directly in the source code. Literals don’t need to be named, they can simply be used directly.

There are times when we only need to use functions once, or temporarily, only requiring the functionality of those functions. Naming them is an extra unnecessary step in this scenario. What we need is something similar to literals. Functions that do not need to be named as their functionality is only required for a single instance.

Dart provides a solution known as anonymous functions.

Anonymous functions are sometimes known as lambda functions or closures.

Create a free account to access the full course.

By signing up, you agree to Educative's Terms of Service and Privacy Policy