I cannot redeclare the "==" operator inside an extension type
extension type Compare(List<int> types) {
@redeclare
bool operator ==(List<int> other) =>true;
}
I get these errors:
Extension types can't declare members with the same name as a member declared by 'Object'. Try specifying a different name for the member
and this
The method doesn't redeclare a method declared in a superinterface. Try updating this member to match a declaration in a superinterface, or removing the redeclare annotation
Is there a way to redeclare it inside an extension type?
Extensions can't declare members with the same name as a member declared by 'Object'.
The analyzer produces this diagnostic when an extension declaration declares a member with the same name as a member declared in the class Object. Such a member can never be used because the member in Object is always found first.
Example:
The following code produces this diagnostic because
toStringis defined byObject:Since members of the
Objectclass can't be overridden in anextension, you should use another name for your desired functionality.Hope it helps you.