Skip to main content

prefer-static-method

has auto-fix
pro+

Suggests converting an instance method to a static method if it does not reference any instance or inherited members.

Example

❌ Bad:

class Child extends Parent {
const Child() : super('hello');

// LINT: This method does not reference any instance members and can be made static.
void some() {
print('hi');
}
}

✅ Good:

class Child extends Parent {
const Child() : super('hello');

void correct() {
super.value;
super.method();
this.value;
}
}