prefer_function_declarations_over_variables

Group: style

Maturity: stable

Dart SDK: >= 2.0.0 • (Linter v0.1.30)

View the Project on GitHub dart-lang/linter

DO use a function declaration to bind a function to a name.

As Dart allows local function declarations, it is a good practice to use them in the place of function literals.

BAD:

void main() {
  var localFunction = () {
    ...
  };
}

GOOD:

void main() {
  localFunction() {
    ...
  }
}