I have a method that I'm overriding:
@override
bool operator ==(Object o) {
if (identical(this, o)) return true;
return o is Song &&
o.id == id &&
o.name == name &&
o.lyrics == lyrics &&
o.url == url;
}
But I get a lint warning from flutter_lints:
Don't rename parameters of overridden methods. dart(avoid_renaming_method_parameters)
What is it complaining about? How do I fix it?
I found the answer so I'm posting below.
When you override a method that takes parameters, you should use the same parameter names as the original method from the super class. If you don't know what they are, look at the super class source code to find out.
In your case you have:
@override
bool operator ==(Object o) {
// ...
}
But if you look at the source code of the super class (probably Object
unless you have some other class that was overriding the equality operator), you'll see the following:
external bool operator ==(Object other);
So to get rid of the warning you should change o
to other
:
@override
bool operator ==(Object other) {
// ...
}