unnecessary_final

Group: style

Maturity: stable

Linter v0.1.104

Since info is static, may be stale

View all Lint Rules

Using the Linter

DON'T use final for local variables.

var is shorter, and final does not change the meaning of the code.

BAD:

void badMethod() {
  final label = 'Final or var?';
  for (final char in ['v', 'a', 'r']) {
    print(char);
  }
}

GOOD:

void goodMethod() {
  var label = 'Final or var?';
  for (var char in ['v', 'a', 'r']) {
    print(char);
  }
}

Incompatible with: prefer_final_locals, prefer_final_parameters.