Skip to main content

avoid-explicit-type-declaration

added in: 1.1.0
🛠
Pro+

Warns when a variable is declared with an explicit type that can be omitted.

Example

❌ Bad:

class SomeClass {
static const String val = '123'; // LINT

final Map<String, String> initedWithType = <String, String>{}; // LINT

final Set<String> elements = {}; // LINT

final (String,) record = ('hello',); // LINT

late final (String,) lazyRecord;
}

✅ Good:

class SomeClass {
static const val = '123';

final initedWithType = <String, String>{};

final elements = <String>{};

final record = ('hello',);

late final (String,) lazyRecord;
}