Skip to content
pubscout

analyzer

14.7.0, released 3 weeks ago by tools.dart.dev

Performs static analysis of Dart code for tool integration and embedding.

$ flutter pub add analyzer
Source repository

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.

  • pedantic_mono

    Recommended lints for Flutter apps, packages, and plugins to encourage good coding practices.

  • skills_lint

    Static analysis linter and CLI tool for Agent Skills (SKILL.md) structure and metadata

  • yumemi_lints

    Customizable linter library enforcing coding standards for Flutter and Dart apps.

Works with

Packages commonly used together with analyzer: ones it builds on, ones built on it, and its own family.