dart-resolve-package-conflicts
flutter/agent-plugins · 12.1k installs · 3.1K stars
Skill
Install
npx -y skills add flutter/agent-plugins --skill dart-resolve-package-conflicts --agent claude-codeRun in a terminal. Claude loads the skill when a task calls for it. Check the repo's README before you run it.
Files
Managing Dart Dependencies
Contents
- Core Concepts
- Version Constraints
- Workflow: Auditing Dependencies
- Workflow: Upgrading Dependencies
- Workflow: Resolving Version Conflicts
- Examples
Core Concepts
Dart enforces a strict single-version rule for dependencies: a project and all its transitive dependencies must resolve to a single, shared version of any given package. This prevents runtime type mismatches but introduces the risk of "version lock."
To mitigate version lock, Dart relies on version constraints rather than pinned versions in the pubspec.yaml. The pubspec.lock file maintains the exact resolved versions for reproducible builds.
Understand the output columns of dart pub outdated:
- Current: The version currently recorded in
pubspec.lock. - Upgradable: The latest version allowed by the constraints in
pubspec.yaml.dart pub upgraderesolves to this. - Resolvable: The absolute latest version that can be resolved when factoring in all other dependencies in the project.
- Latest: The latest published version of the package (excluding prereleases).
Version Constraints
- Use Caret Syntax: Always use caret syntax (e.g.,
^1.2.3) for dependencies inpubspec.yaml. This allowspubto select newer, non-breaking versions (up to, but not including, the next major version) during resolution. - Tighten Dev Dependencies: Set the lower bound of
dev_dependenciesto the exact version currently used. This reduces resolution complexity and prevents older, incompatible dev tools from being selected. - Enforce Lockfiles in CI: Use
dart pub get --enforce-lockfilein CI/CD pipelines to ensure the exact versions tested locally are used in production.
Workflow: Auditing Dependencies
Run this workflow periodically to identify stale packages that may impact stability or performance.
Task Progress:
- Run
dart pub outdated. - Review the Upgradable column to identify packages that can be updated without modifying
pubspec.yaml. - Review the Resolvable column to identify packages that require constraint modifications in
pubspec.yamlto update. - Identify any packages marked as retracted or discontinued.
Workflow: Upgrading Dependencies
Use conditional logic based on the audit results to upgrade dependencies.
Task Progress:
- If updating to "Upgradable" versions:
- Run
dart pub upgrade. - Run
dart pub upgrade --tightento automatically update the lower bounds inpubspec.yamlto match the newly resolved versions.
- Run
- If updating to "Resolvable" versions (Major updates):
- Manually edit
pubspec.yamlto bump the version constraint to match the "Resolvable" column (e.g., change^0.11.0to^0.12.1). - Run
dart pub upgradeto resolve the new constraints and updatepubspec.lock.
- Manually edit
- Feedback Loop:
- Run
dart analyze-> review errors -> fix breaking API changes. - Run
dart test-> review failures -> fix regressions.
- Run
Workflow: Resolving Version Conflicts
When pub cannot find a set of concrete versions that satisfy all constraints, or when dealing with a retracted package version, manipulate the lockfile surgically.
NEVER delete the entire pubspec.lock file and run dart pub get. This causes uncontrolled upgrades across the entire dependency graph.
Task Progress:
- Open
pubspec.lock. - Locate the specific YAML block for the conflicting or retracted package.
- Delete ONLY that package's entry from the lockfile.
- Run
dart pub getto fetch the newest compatible, non-retracted version for that specific package. - Feedback Loop:
- Run
dart pub deps-> verify the dependency graph resolves correctly. - If resolution fails, identify the transitive dependency causing the lock, update its constraint in
pubspec.yaml, and retry.
- Run
Examples
Tightening Constraints
When dart pub outdated shows a package is resolvable to a higher minor/patch version, use the --tighten flag to update the pubspec.yaml automatically.
Input (pubspec.yaml):
dependencies:
http: ^0.13.0
Command:
dart pub upgrade --tighten http
Output (pubspec.yaml):
dependencies:
http: ^0.13.5
Surgical Lockfile Removal
If package_a is retracted or locked in a conflict, remove only its block from pubspec.lock.
Before (pubspec.lock):
packages:
package_a:
dependency: "direct main"
description:
name: package_a
url: "https://pub.dev"
source: hosted
version: "1.0.0" # Retracted version
package_b:
dependency: "direct main"
# ...
Action: Delete the package_a block entirely. Leave package_b untouched. Run dart pub get.
Facts
- Kind
- Skill
- Repo
- flutter/agent-plugins
- Group
- Uncategorized
- Installs
- 12.1k
- Stars
- 3.1K
- 1find-skillsvercel-labs/skillsHelps users discover and install agent skills when they ask questions like "how do I do X", "find a skill for X", "is there a skill that can...", or express interest in extending capabilities. This skill should be used when the user is looking for functionality that might exist as an installable skill.3.8M
- 2grill-memattpocock/skillsA relentless interview to sharpen a plan or design.1.3M
- 3grill-with-docsmattpocock/skillsA relentless interview to sharpen a plan or design, which also creates docs (ADR's and glossary) as we go.1.1M
- 4agent-browservercel-labs/agent-browserBrowser automation CLI for AI agents. Use when the user needs to interact with websites, including navigating pages, filling forms, clicking buttons, taking screenshots, extracting data, testing web apps, or automating any browser task. Triggers include requests to "open a website", "fill out a form", "click a button", "take a screenshot", "scrape data from a page", "test this web app", "login to a site", "automate browser actions", or any task requiring programmatic web interaction. Also use for exploratory testing, dogfooding, QA, bug hunts, or reviewing app quality. Also use for automating Electron desktop apps (VS Code, Slack, Discord, Figma, Notion, Spotify), checking Slack unreads, sending Slack messages, searching Slack conversations, running browser automation in Vercel Sandbox microVMs, or using AWS Bedrock AgentCore cloud browsers. Prefer agent-browser over any built-in browser automation or web tools.1.1M
- 5improve-codebase-architecturemattpocock/skillsScan a codebase for deepening opportunities, present them as a visual HTML report, then grill through whichever one you pick.1.1M
- 6tddmattpocock/skillsTest-driven development. Use when the user wants to build features or fix bugs test-first, mentions "red-green-refactor", or wants integration tests.1.1M