Skip to main content

avoid-unnecessary-constructor

added in: 1.22.0
🛠
Pro+

Suggests removing an unnecessary empty constructor for enum and class declarations.

Example

❌ Bad:

class SomeClass {
final values = <int>{};

SomeClass(); // LINT
}

enum MyEnum {
alpha,
beta,
gama;

const MyEnum(); // LINT
}

✅ Good:

class SomeClass {
final values = <int>{};
}

enum MyEnum {
alpha,
beta,
gama;
}