unnecessary_overrides
Unnecessary override.
Description
#The analyzer produces this diagnostic when an instance member overrides an inherited member but only invokes the overridden member with exactly the same arguments.
Example
#The following code produces this diagnostic because the method D.m
doesn't do anything other than invoke the overridden method:
class C {
int m(int x) => x;
}
class D extends C {
@override
int m(int x) => super.m(x);
}
Common fixes
#If the method should do something more than what the overridden method does, then implement the missing functionality:
class C {
int m(int x) => x;
}
class D extends C {
@override
int m(int x) => super.m(x) + 1;
}
If the overridden method should be modified by changing the return type or one or more of the parameter types, making one of the parameters covariant
, having a documentation comment, or by having additional annotations, then update the code:
import 'package:meta/meta.dart';
class C {
int m(int x) => x;
}
class D extends C {
@mustCallSuper
@override
int m(int x) => super.m(x);
}
If the overriding method doesn't change or enhance the semantics of the code, then remove it:
class C {
int m(int x) => x;
}
class D extends C {}
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.