dot_ shorthand_ undefined_ member
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}
Unless stated otherwise, the documentation on this site reflects Dart 3.9.2. Page last updated on 2025-9-4. View source or report an issue.