Dart Analyze logoDart Analyze/
DRT-W1160

Use trailing commas for all function calls and declarationsDRT-W1160

Major severityMajor
Anti-pattern categoryAnti-pattern

DO use trailing commas for all function calls and declarations unless the function call or definition, from the start of the function name up to the closing parenthesis, fits in a single line.

BAD:

void run() {
  method('does not fit on one line',
      'test test test test test test test test test test test');
}

GOOD:

void run() {
  method(
    'does not fit on one line',
    'test test test test test test test test test test test',
  );
}

EXCEPTION: If the final parameter/argument is positional (vs named) and is either a function literal implemented using curly braces, a literal map, a literal set or a literal array. This exception only applies if the final parameter does not fit entirely on one line.

NOTE: This lint rule assumes dart format has been run over the code and may produce false positives until that has happened.