dartanalyzer: The Static Analyzer

You can use the dartanalyzer tool (bin/dartanalyzer) to statically analyze your code at the command line, checking for errors and warnings that are specified in the Dart Language Specification. Dart Editor performs the same analysis that dartanalyzer does.

Basic usage

Run the analyzer from the top directory of the package. Here’s an example of testing a Dart file.

dartanalyzer bin/test.dart

As the following table shows, the exit code of dartanalyzer tells you whether the code passed analysis.

Exit code Description
0 No issues found
1 Hints found (but no warnings or errors)
2 Warnings found
3 Errors found


You can use the following command-line options with dartanalyzer:

Specify the directory that contains the Dart SDK.
-p or --package-root=
Deprecated. Specify the directory to search for any libraries that are imported using package:.
Show warnings not only for code in the specified .dart file and others in its library, but also for libraries imported with package:.
Produce output in a format suitable for parsing.
Don’t show hints for improving the code.
Show the analyzer version.
-h or --help
Show all the command-line options.