Dart Function Anonymous Function & Lambda Exprerssion

Dart Function Anonymous Function & Lambda Exprerssion

·

1 min read

Lambda Expression

  • Lambda functions are a short and simple way to express tiny functions.

  • Lambda functions are also known as anonymous functions or closures.

  • They are functions without a name that can be used inline within the code.

  •   return_type var_name = (parameters)=> expression;
    

Dart Anonymous Function

  • An anonymous function can have zero or more parameters with optional type annotations.

  • An anonymous function consists of self-contained blocks of code and that can be passed around in our code as a function parameter.

  •   Syntax:
      (parameter_list)
      {
           statement(s)
    
      }