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() {}
}
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.