Skip to main content

prefer-visible-for-testing-on-members

added in: 1.4.0
🛠

Warns when the @visibleForTesting annotation is applied to the class declaration.

Applying this annotation to the class declaration does not stop the class members from being accessed from outside of the tests. Instead, add this annotation to particular class members.

Example

❌ Bad:

 // LINT
class SomeClass {
final String someState;

SomeWidget(this.someState);

bool get getter => someState.isEmpty;

void someMethod(String value) {
// ...
}
}

✅ Good:

class SomeClass {
final String someState;


SomeWidget(this.someState);

bool get getter => someState.isEmpty;


void someMethod(String value) {
// ...
}
}