omit_local_variable_types

Group: style

Maturity: stable

Linter v0.1.30

Since info is static, may be stale
pedantic

View all Lint Rules

Using the Linter

CONSIDER omitting type annotations for local variables.

Usually, the types of local variables can be easily inferred, so it isn't necessary to annotate them.

BAD:

Map<int, List<Person>> groupByZip(Iterable<Person> people) {
  Map<int, List<Person>> peopleByZip = <int, List<Person>>{};
  for (Person person in people) {
    peopleByZip.putIfAbsent(person.zip, () => <Person>[]);
    peopleByZip[person.zip].add(person);
  }
  return peopleByZip;
}

GOOD:

Map<int, List<Person>> groupByZip(Iterable<Person> people) {
  var peopleByZip = <int, List<Person>>{};
  for (var person in people) {
    peopleByZip.putIfAbsent(person.zip, () => <Person>[]);
    peopleByZip[person.zip].add(person);
  }
  return peopleByZip;
}

Incompatible with: always_specify_types.