analyzer
14.7.0, released 3 weeks ago by tools.dart.dev
Performs static analysis of Dart code for tool integration and embedding.
What it does
Provides a library for performing static analysis on Dart code. It allows developers to configure analysis options, examine elements, and build custom IDE tools, formatters, or documentation generators.
AI-written summary of version 14.7.0, based on the package's README and metadata. Report an inaccuracy
Use it when
- You are building a custom Dart tool or editor integration
- You need to programmatically analyze Dart source code and inspect elements
Skip it when
- You just want to run standard linting on your project (use the built-in `dart analyze` command instead)
- You are an end-user looking for a command-line analysis tool
Strengths
- Powers major Dart tooling like dart format and dart doc
- Supports fine-grained analysis options and custom lint rules
Weaknesses
- APIs were originally machine generated from a Java implementation and may not feel like clean Dart APIs
- No clean distinction currently between public and internal APIs, leading to potential breaking changes
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 12
Add the dependency to pubspec.yaml and optionally configure an analysis_options.yaml file in your project root.
import 'package:analyzer/dart/analysis/analysis_context_collection.dart';
// Basic usage example outline
void analyzePath(String path) {
final collection = AnalysisContextCollection(includedPaths: [path]);
for (final context in collection.contexts) {
// process context...
}
}Alternatives
Packages that do the same job and could replace analyzer.
- ciach
Dead code detector for Dart and Flutter that finds and removes unused declarations.
80Compare - pedantic_mono
Recommended lints for Flutter apps, packages, and plugins to encourage good coding practices.
85Compare - skills_lint
Static analysis linter and CLI tool for Agent Skills (SKILL.md) structure and metadata
83Compare - yumemi_lints
Customizable linter library enforcing coding standards for Flutter and Dart apps.
79Compare
Works with
Packages commonly used together with analyzer: ones it builds on, ones built on it, and its own family.
- yamlanalyzer depends on itA Dart library for parsing YAML documents into Dart data structures.
- cryptoanalyzer depends on itProvides SHA, MD5, and HMAC hashing functions for Dart.
- pub_semveranalyzer depends on itVersions and version constraints implementing pub's versioning policy.
- globanalyzer depends on itA file and directory globbing library that supports Bash-style path matching and listing.
- package_configanalyzer depends on itRead and write Dart package configuration files.
- source_spananalyzer depends on itStandard representation for source code locations, spans, and human-friendly error messages.
- watcheranalyzer depends on itMonitors file system changes and notifies when files are added, removed, or modified.
- convertanalyzer depends on itEncoders and decoders for converting between different data representations.