instance_access_to_static_member
The static {1} '{0}' can't be accessed through an instance.
Description
#The analyzer produces this diagnostic when an access operator is used to access a static member through an instance of the class.
Example
#The following code produces this diagnostic because zero
is a static
field, but it's being accessed as if it were an instance field:
dart
void f(C c) {
c.zero;
}
class C {
static int zero = 0;
}
Common fixes
#Use the class to access the static member:
dart
void f(C c) {
C.zero;
}
class C {
static int zero = 0;
}
除非另有说明,文档之所提及适用于 Dart 3.7.3 版本,本页面最后更新时间: 2025-05-08。 查看文档源码 或者 报告页面问题。