Description
Per Effective Dart:
AVOID redundant type arguments on generic invocations.
A type argument is redundant if inference would fill in the same type. If the invocation is the initializer for a type-annotated variable, or is an argument to a function, then inference usually fills in the type
Set<String> things = Set();
(good)
Set<String> things = Set<String>();
(bad)
Here, the type annotation on the variable is used to infer the type argument of constructor call in the initializer.
In other contexts, there isn’t enough information to infer the type and then you should write the type argument:
var things = Set<String>();
(good)
var things = Set();
(bad)
Here, since the variable has no type annotation, there isn’t enough context to determine what kind of Set to create, so the type argument should be provided explicitly.
But with the following code:
const Set<String> temp = {};
I get the following:
INFO|LINT|... Specify type annotations.
This comes from the rule always_specify_types
.