invalid_visible_for_overriding_annotation
The annotation 'visibleForOverriding' can only be applied to a public instance member that can be overridden.
Description
#The analyzer produces this diagnostic when anything other than a public
instance member of a class is annotated with
visibleForOverriding
. Because only public
instance members can be overridden outside the defining library, there's
no value to annotating any other declarations.
Example
#The following code produces this diagnostic because the annotation is on a class, and classes can't be overridden:
dart
import 'package:meta/meta.dart';
@visibleForOverriding
class C {}
Common fixes
#Remove the annotation:
dart
class C {}
除非另有说明,文档之所提及适用于 Dart 3.7.3 版本,本页面最后更新时间: 2025-05-08。 查看文档源码 或者 报告页面问题。