Skip to main content

prefer-abstract-final-static-class

added in: 1.18.0
🛠
Pro+

Suggests adding abstract final to classes with only static members to avoid them being instantiated or being used in inheritance.

Example

❌ Bad:

// LINT: Add 'abstract final' to classes with only static members to avoid instantiation and use in inheritance.
class Static {
static final field = 'some value';
}

✅ Good:

abstract final class Static {
static final field = 'some value';
}

class SomeOtherClass { // Correct, has instance members
final String value;

const SomeOtherClass(this.value);
}