dot_ shorthand_ undefined_ member
Details about the 'dot_shorthand_undefined_member' diagnostic produced by the Dart analyzer.
The static getter '{0}' isn't defined for the context type '{1}'.
The static method or constructor '{0}' isn't defined for the context type '{1}'.
Description
#The analyzer produces this diagnostic when a dot shorthand is used to reference a member, but that member doesn't exist.
Example
#
The following code produces this diagnostic because the enum
E doesn't define a static member named
c:
void f() {
E e = .c;
print(e);
}
enum E { a, b }
Common fixes
#
If the name is correct, then define a member with that name in
the context type, which in this case is the enum
E:
void f() {
E e = .c;
print(e);
}
enum E { a, b, c }
If the name is not correct, then replace the name with the
name of an existing member from the context type, which in
this case is the enum E:
void f() {
E e = .b;
print(e);
}
enum E { a, b }
除非另有说明,文档之所提及适用于 Dart 3.12.2 版本报告页面问题.