omit_local_variable_types

Group: style

Maturity: stable

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

View the Project on GitHub dart-lang/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;
}