undefined_ super_ member_ read
Details about the 'undefined_super_member_read' diagnostic produced by the Dart analyzer.
The member '{0}' is declared in '{1}', but private names are visible only in their own library.
The member '{0}' isn't defined in a superclass of '{1}'.
There's a setter '{0}' in a superclass of '{1}', but no getter.
Description
#
The analyzer produces this diagnostic when a member is read, invoked, or
torn off using super, but no superclass of the enclosing declaration
has a method, getter, or field with that name.
Examples
#
The following code produces this diagnostic because the superclass A
doesn't define a member named bar:
class A {
void foo() {}
}
class B extends A {
void m() {
super.bar();
}
}
The following code produces this diagnostic because the superclass A
defines only a setter named foo, which can't be read:
class A {
set foo(int _) {}
}
class B extends A {
int m() => super.foo;
}
Common fixes
#If the inherited member you intend to use has a different name, then make the name match the inherited member:
class A {
void foo() {}
}
class B extends A {
void m() {
super.foo();
}
}
If the member isn't defined, then add it to a superclass:
class A {
void foo() {}
void bar() {}
}
class B extends A {
void m() {
super.bar();
}
}
If a superclass defines only a setter, then add a getter with the same name:
class A {
int get foo => 0;
set foo(int _) {}
}
class B extends A {
int m() => super.foo;
}
Otherwise, remove the reference.
Unless stated otherwise, the documentation on this site reflects Dart 3.13.3. Report an issue.