Ignoring lint warnings in Dart

Sometimes the Dart compiler warns you about a potential mistake that is actually intentional:

line 19 col 37: The value of the field '_delegate' isn't used.

The message above is a "health tip" that pub.dev left on my package, but it doesn't tell you how to ignore it.

In Visual Studio Code, with the Dart plugin, it'll run the same analysis, and show you the error code:

You can also run the same analyzer as a command-line:

dartanalyzer lib

So to ignore the error, add the following comment above the offending line:

// ignore: unused_field



I've also used this annotation when working with test related code:

// ignore: invalid_use_of_visible_for_testing_member