dart_dependency_checker library

A utility package for checking dependencies within Dart/Flutter packages. This utilities can be used directly by depending on this package or through a command-line dart_dependency_checker_cli wrapper.

Usage

Install:

dart pub add dart_dependency_checker

Use:

import 'package:dart_dependency_checker/dart_dependency_checker.dart';

void main() {
  const depsUnusedChecker = DepsUnusedChecker(
    DepsUnusedParams(
      path: '.',
      mainIgnores: {'meta'},
      devIgnores: {'build_runner'},
      fix: true, // Danger zone! Use with caution.
    ),
  );

  const transitiveUseChecker = TransitiveUseChecker(
    TransitiveUseParams(
      path: '.',
      mainIgnores: {},
      devIgnores: {'args', 'convert'},
    ),
  );

  try {
    print(depsUnusedChecker.check());
    print(transitiveUseChecker.check());
  } on CheckerError catch (e) {
    print(e.message);
  }
}

Classes

BaseResults
Checker<I, O>
Base checker class.
DepsUnusedChecker
Checks declared but unused dependencies.
DepsUnusedParams
Params for the DepsUnusedChecker.
DepsUnusedResults
Results from the DepsUnusedChecker.
TransitiveUseChecker
Checks direct use of undeclared/transitive dependencies.
TransitiveUseParams
Params for the TransitiveUseChecker.
TransitiveUseResults
Results from the TransitiveUseChecker.

Exceptions / Errors

CheckerError
Base class for PubspecNotFoundError and PubspecNotValidError.
PubspecNotFoundError
Thrown when the pubspec.yaml was not found.
PubspecNotValidError
Thrown when the pubspec.yaml contents were invalid.