Skip to main content

avoid-unnecessary-enum-arguments

added in: 1.22.0
🛠
Pro+
preset: recommended

Warns when a enum constant has an unnecessary empty argument list.

Example

❌ Bad:

enum MyEnum {
alpha.named(),
beta.named(),
gama(); // LINT: This argument list is unnecessary. Try removing it.

final String value;

const MyEnum.named() : value = '2';

const MyEnum() : value = '3';
}

✅ Good:

enum MyEnum {
alpha.named(),
beta.named(),
gama; // Correct, no argument list

final String value;

const MyEnum.named() : value = '2';

const MyEnum() : value = '3';
}