unqualified_reference_to_static_member_of_extended_type
Static members from the extended type or one of its superclasses must be qualified by the name of the defining type.
Description
#The analyzer produces this diagnostic when an undefined name is found, and the name is the same as a static member of the extended type or one of its superclasses.
Example
#The following code produces this diagnostic because m
is a static member
of the extended type C
:
class C {
static void m() {}
}
extension E on C {
void f() {
m();
}
}
Common fixes
#If you're trying to reference a static member that's declared outside the extension, then add the name of the class or extension before the reference to the member:
class C {
static void m() {}
}
extension E on C {
void f() {
C.m();
}
}
If you're referencing a member that isn't declared yet, add a declaration:
class C {
static void m() {}
}
extension E on C {
void f() {
m();
}
void m() {}
}
除非另有说明,文档之所提及适用于 Dart 3.7.3 版本,本页面最后更新时间: 2025-05-08。 查看文档源码 或者 报告页面问题。