redeclare_ on_ non_ redeclaring_ member
Details about the 'redeclare_on_non_redeclaring_member' diagnostic produced by the Dart analyzer.
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.12.2 版本报告页面问题.