extension_type_declares_member_of_object
Extension types can't declare members with the same name as a member declared by 'Object'.
Description
#The analyzer produces this diagnostic when the body of an extension type declaration contains a member with the same name as one of the members declared by Object
.
Example
#The following code produces this diagnostic because the class Object
already defines a member named hashCode
:
extension type E(int i) {
int get hashCode => 0;
}
Common fixes
#If you need a member with the implemented semantics, then rename the member:
extension type E(int i) {
int get myHashCode => 0;
}
If you don't need a member with the implemented semantics, then remove the member:
extension type E(int i) {}
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.