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() {}
}
除非另有说明,文档之所提及适用于 Dart 3.7.3 版本,本页面最后更新时间: 2025-05-08。 查看文档源码 或者 报告页面问题。