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:
dart
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:
dart
void _someFunction() {}
void f() => _someFunction();
If it does, then make it public:
dart
import 'package:meta/meta.dart';
@visibleForTesting
void someFunction() {}
void f() => someFunction();
除非另有说明,文档之所提及适用于 Dart 3.7.3 版本,本页面最后更新时间: 2025-05-08。 查看文档源码 或者 报告页面问题。