annotate_overrides
The member '{0}' overrides an inherited member but isn't annotated with '@override'.
Description
#The analyzer produces this diagnostic when a member overrides an inherited
member, but isn't annotated with @override
.
Example
#The following code produces this diagnostic because the method m
in the
class B
overrides the method with the same name in class A
, but isn't
marked as an intentional override:
class A {
void m() {}
}
class B extends A {
void m() {}
}
Common fixes
#If the member in the subclass is intended to override the member in the
superclass, then add an @override
annotation:
class A {
void m() {}
}
class B extends A {
@override
void m() {}
}
If the member in the subclass is not intended to override the member in the superclass, then rename one of the members:
class A {
void m() {}
}
class B extends A {
void m2() {}
}
除非另有说明,文档之所提及适用于 Dart 3.7.3 版本,本页面最后更新时间: 2025-05-08。 查看文档源码 或者 报告页面问题。