Dart
Have you ever seen an error message.
Let’s take a fairly common example. There’s a problem in the following code:
It seems odd that there’s a problem because we just checked that values
isn’t null
on the line above.
The message tells us what’s wrong, but it doesn’t really help us understand why the check wasn’t sufficient or how to respond to the error. That extra information is actually available; it just might not be obvious how to find it.
Although the Dart Analysis view displays only the problem message, double-clicking the message navigates you to the text with the red squiggly underline where the problem is being reported. For other useful features, bring up the context menu:
With the context menu, you can navigate to either the location where the diagnostic was reported (using Jump to Source, which works just like double-clicking the problem message) or to the declaration of values
(using the menu item labeled by the context message). Selecting Open Documentation opens the external documentation about the diagnostic.
Visual Studio Code
In Visual Studio Code there are two ways to see the extra information. The first is to expand the entry in the Problems panel:
values
. The context message includes the URL of additional documentation related to type promotion.Summary
I hope this article helps you more easily find the information you need to understand the analyzer’s diagnostics.
If you find diagnostics that are still hard to understand — because the message isn’t clear, it needs a context message to help you find other related code locations, or the documentation isn’t complete enough — please let us know by creating a dart-lang/sdk issue. We’re always interested in improving the tools.