mcpField
D
dart-tooling

dart-tooling

github.com/dhruvanbhalaraDevelopment3066 installsUpdated 8w ago
Repository

About dart-tooling

A workflow skill for developers maintaining Dart projects, with procedures for static analysis, dependency conflicts, and migrating tests to package:checks. It emphasizes targeted dependency updates and verification with analysis and tests.

Key features

  1. 01Static analysis and automated fix workflow
  2. 02Package version conflict resolution
  3. 03Targeted lockfile updates
  4. 04Dependency upgrade verification
  5. 05Migration to package:checks

Use cases

  1. 01Diagnose and fix Dart analyzer findings
  2. 02Resolve incompatible pub package versions
  3. 03Update one conflicting lockfile entry
  4. 04Convert matcher assertions to package:checks

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/dhruvanbhalara/skills --skill dart-tooling

After installing, type/dart-toolingin Claude Code to confirm it loaded.

Details

From the project README

Dart Tooling & Package Workflows

Contents

Static Analysis Resolution

Use this sequential workflow to identify, fix, and verify static analysis errors in a Dart project.

  1. Run Static Analyzer: dart analyze . --fatal-infos
  2. Apply Automated Fixes:
    • dart fix --dry-run
    • dart fix --apply
  3. Resolve Manually: Address Type Mismatches, Null Safety, or Invalid Overrides that dart fix couldn't automatically resolve.
  4. Performance Diagnostics: Utilize the Analysis Server diagnostics page (available at http://localhost:8082 when analyzer runs) to trace and diagnose slow analysis times.
  5. Verify: Ensure both dart analyze . and dart test pass.

Resolving Package Conflicts

When pub get fails due to incompatible package versions, use this systematic approach.

Understanding dart pub outdated
ColumnMeaning
CurrentVersion in pubspec.lock right now
UpgradableLatest version allowed by pubspec.yaml constraints
ResolvableLatest version that CAN be resolved with all other deps
LatestLatest published version (ignoring constraints)
dart pub outdated
Git LFS Support

Introduced in Dart 3.12

  • The dart pub package management command natively supports Git Large File Storage (LFS). Dependencies fetched from Git repositories that contain LFS objects (e.g. assets, binaries, models) resolve automatically without requiring local configuration.
Version Constraint Best Practices
  • Use Caret Syntax: Always use ^1.2.3 - allows non-breaking updates up to next major version.
  • Tighten Dev Dependencies: Set lower bounds to exact current version for dev_dependencies.
  • CI Reproducibility: Use dart pub get --enforce-lockfile in CI to ensure exact tested versions.
Upgrading Dependencies

If updating to "Upgradable" versions:

dart pub upgrade
dart pub upgrade --tighten  # Auto-update lower bounds in pubspec.yaml

If updating to "Resolvable" versions (major):

  1. Manually edit pubspec.yaml to bump constraints.
  2. Run dart pub upgrade.
  3. Run dart analyze → fix breaking API changes.
  4. Run dart test → fix regressions.
Surgical Lockfile Removal

NEVER delete the entire pubspec.lock. This causes uncontrolled upgrades across the dependency graph.

Instead, remove ONLY the conflicting package's block:

  1. Open pubspec.lock.
  2. Find and delete ONLY the conflicting package's YAML block.
  3. Run dart pub get: fetches newest compatible version for that package only.
  4. Verify: dart pub deps → check dependency graph resolves correctly.
Temporary Overrides (Last Resort)
dependency_overrides:
  shared_package: ^x.y.z  # Remove once direct deps support newer version

Migrating Tests to package:checks

Transition test assertions from the package:matcher syntax to the literate API provided by package:checks for more readable output.

  • Dependency: Add dev_dependency checks via dart pub add dev:checks.
  • Basic Equality: Replace expect(actual, equals(expected)) with check(actual).equals(expected).
  • Type Checking: Replace expect(actual, isA<Type>()) with check(actual).isA<Type>().
  • Asynchronous Expectations:
    • await check(Future.value(10)).completes((it) => it.equals(10));
  • Workflow:
    1. Add package:checks and import package:checks/checks.dart.
    2. Rewrite expect() calls to check().
    3. Run static analyzer and tests to verify.

Comments

Markdown supported