prefer-visible-for-testing-on-members
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: This 'visibleForTesting' annotation does not prevent the class instantiation. Try annotating individual members instead.
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) {
// ...
}
}