dep_audit library

A lightweight dependency & package health auditor for Dart/Flutter projects.

This library provides tools to audit your project dependencies for:

  • Outdated packages that have newer versions available
  • Unused dependencies that are declared but not imported
  • Discontinued or stale packages that may need attention
  • Automatic fixing capabilities to update and clean dependencies

Usage

import 'package:dep_audit/dep_audit.dart';

// Parse dependencies from pubspec.yaml
final dependencies = parsePubspec(pubspecFile);

// Scan for package imports in source code
final usedPackages = scanForPackageImports(projectDirectory);

// Run a complete audit
await runAudit(AuditOptions(projectPath: '.'));

Classes

AuditOptions
Configuration options for running a dependency audit.
AuditResult
The result of auditing a single dependency.
DependencyInfo
Represents information about a dependency declared in pubspec.yaml.
PackageMetadata
Metadata about a package fetched from pub.dev.
PubDevClient
HTTP client for fetching package metadata from pub.dev.

Enums

AuditStatus
The status of a dependency after auditing.

Functions

enrichDependenciesFromLockfile(List<DependencyInfo> deps, File lockfile) List<DependencyInfo>
Enriches dependency information with locked versions from pubspec.lock.
formatReport(List<AuditResult> results, String format) String
Formats audit results into the specified output format.
parsePubspec(File pubspec) List<DependencyInfo>
Parses a pubspec.yaml file and extracts dependency information.
runAudit(AuditOptions options) Future<void>
Runs a comprehensive dependency audit on the specified project.
scanContentForPackageImports(String content) Set<String>
Scans content for package imports.
scanContentsForPackageImports(Iterable<String> contents) Set<String>
Scans multiple content strings for package imports.
scanForPackageImports(dynamic root) Set<String>
Scans a project directory for package imports in Dart source files.