redeclare_on_non_redeclaring_member
The {0} doesn't redeclare a {0} declared in a superinterface.
Description
#The analyzer produces this diagnostic when a member of an extension type is annotated with @redeclare
, but none of the implemented interfaces has a member with the same name.
Example
#The following code produces this diagnostic because the member n
declared by the extension type E
is annotated with @redeclare
, but C
doesn't have a member named n
:
import 'package:meta/meta.dart';
class C {
void m() {}
}
extension type E(C c) implements C {
@redeclare
void n() {}
}
Common fixes
#If the annotated member has the right name, then remove the annotation:
class C {
void m() {}
}
extension type E(C c) implements C {
void n() {}
}
If the annotated member is suppose to replace a member from the implemented interfaces, then change the name of the annotated member to match the member being replaced:
import 'package:meta/meta.dart';
class C {
void m() {}
}
extension type E(C c) implements C {
@redeclare
void m() {}
}
Unless stated otherwise, the documentation on this site reflects Dart 3.7.3. Page last updated on 2025-05-08. View source or report an issue.