Issue
In terms of creating classes which involve inheritance, some actually need the annotation of override. When working with PolymerDart though, specifically
@override
attached(){...}
I see no reason why i need it. It works as expected without it.
Since it is just an annotation, is it just for Developers to see so they understand that function is overriding some other function?
My bet is that it is just for developers, and unlike other annotations which carry out some sort of execution, these do not.
Solution
If you enable the linter rule annotate_overrides the DartAnalyzer provides hints
- for members that override other members of superclasses or interfaces, but don’t have the
@override
annotation - for members that have the
@override
annotation, but don’t actually override other members of superclasses or interfaces.
The @override
annotation is helpful if it is used consistently, because it shows when a member is an override.
The linter rule ensures that it is used consistently.
There is also the `overridden_fields lint, but AFAIK this is going to be deprecated because. This was forbidden until recently in Dart Development compiler but this restriction was removed. I don’t know if it is still discouraged, but there are cases where it makes sense and therefore I think the linter rule shouldn’t be used anymore because it is prone to cause hints for valid code.
Answered By – Günter Zöchbauer
Answer Checked By – Mildred Charles (FlutterFixes Admin)