unqualified_reference_to_non_local_static_member
Static members from supertypes must be qualified by the name of the defining type.
Description
#The analyzer produces this diagnostic when code in one class references a static member in a superclass without prefixing the member's name with the name of the superclass. Static members can only be referenced without a prefix in the class in which they're declared.
Example
#The following code produces this diagnostic because the static field x
is
referenced in the getter g
without prefixing it with the name of the
defining class:
dart
class A {
static int x = 3;
}
class B extends A {
int get g => x;
}
Common fixes
#Prefix the name of the static member with the name of the declaring class:
dart
class A {
static int x = 3;
}
class B extends A {
int get g => A.x;
}
除非另有说明,文档之所提及适用于 Dart 3.7.3 版本,本页面最后更新时间: 2025-05-08。 查看文档源码 或者 报告页面问题。