invalid_visibility_annotation
The member '{0}' is annotated with '{1}', but this annotation is only meaningful on declarations of public members.
Description
#The analyzer produces this diagnostic when either the visibleForTemplate
or visibleForTesting
annotation is applied to a non-public declaration.
Example
#The following code produces this diagnostic:
import 'package:meta/meta.dart';
@visibleForTesting
void _someFunction() {}
void f() => _someFunction();
Common fixes
#If the declaration doesn't need to be used by test code, then remove the annotation:
void _someFunction() {}
void f() => _someFunction();
If it does, then make it public:
import 'package:meta/meta.dart';
@visibleForTesting
void someFunction() {}
void f() => someFunction();
Unless stated otherwise, the documentation on this site reflects Dart 3.7.3. Page last updated on 2025-05-08. View source or report an issue.