invalid_annotation_target hides other errors

In my analysis_options.yaml, I have enabled the invalid_annotation_target rule like so:

    invalid_annotation_target: ignore

My project was displaying 0 problems. But I was starting to suspect that something was behaving strangely and I disabled the rule. More than 30 errors were found in my project, among which most of them were:

I do now understand why there errors are not displayed when invalid_annotation_target is set to ignore?


  • You should put invalid_annotation_target in analyzer errors, not linter rules. So your analysis_options.yaml should look like this:

    include: package:flutter_lints/flutter.yaml
        invalid_annotation_target: ignore

    This will allow the linter rules you mentioned above to work back as normal.

    More info on customizing static analysis and its behavior: https://dart.dev/tools/analysis