dart-resolve-package-conflicts
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.
More from dart-lang/skills
dart-add-unit-test
Write and organize unit tests for functions, methods, and classes using `package:test`. Use when creating new logic or fixing bugs to ensure code remains correct and regression-free.
2.1Kdart-fix-runtime-errors
Uses get_runtime_errors and lsp to fetch an active stack trace, locate the failing line, apply a fix, and verify resolution via hot_reload.
2.1Kdart-run-static-analysis
Execute `dart analyze` to identify warnings and errors, and use `dart fix --apply` to automatically resolve mechanical lint issues. Use during development to ensure code quality and before committing changes.
2.1Kdart-use-pattern-matching
Use switch expressions and pattern matching where appropriate
2.1Kdart-collect-coverage
Collect coverage using the coverage packge and create an LCOV report
2.0Kdart-generate-test-mocks
Define and generate mock objects for external dependencies using `package:mockito` and `build_runner`. Use when unit testing classes that depend on complex external services like APIs or databases.
2.0K