Version Constraints and the Lock File
The http line in Sprout's pubspec.yaml says ^1.2.0, yet your machine is using version 1.2.2. A teammate's might pick something else next month. To reason about that, you need to read two things: the constraint you wrote, and the lock file pub wrote for you.
The rule
The caret allows everything up to the next breaking version; the lock file pins one.
Dart packages use semantic versioning: major.minor.patch.
- Patch (1.2.2): bug fixes.
- Minor (1.3.0): new features, nothing removed.
- Major (2.0.0): may break existing code.
A caret constraint accepts any version that should be compatible:
| Constraint | Allows | Stops before |
|---|---|---|
^1.2.0 |
1.2.0, 1.2.9, 1.9.4 | 2.0.0 |
^0.4.1 |
0.4.1, 0.4.7 | 0.5.0 |
For packages still below 1.0, the minor number plays the role of the breaking one, so the caret stops at the next minor.
Other forms exist, such as an exact 1.2.0 or a range '>=1.2.0 <1.5.0', but the caret is the normal choice and what pub add writes.
pubspec.lock records the single version pub actually chose for every package, including the packages your packages depend on:
http:
dependency: "direct main"
source: hosted
version: "1.2.2"flutter pub get reuses those locked versions. Only flutter pub upgrade (or changing a constraint) chooses new ones.