Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why flutter `pub get` change pubspec.lock?

When I execute flutter pub get or pub get, these changes their pubspec.lock sometimes like below.

sdks:
-  dart: ">=2.10.2 <=2.11.0-213.1.beta"
+  dart: ">=2.10.2 <2.11.0"

I thought pub get is nealy equal to CocoaPods command pod install which does not modify lock file.
Why pub get update lock file?

like image 864
Satoshi Nagasaka Avatar asked Jan 18 '26 17:01

Satoshi Nagasaka


2 Answers

refering to the officiel docummentaion here

this is the answer :

When pub get gets new dependencies, it writes a lockfile to ensure that future gets will use the same versions of those dependencies. Application packages should check in the lockfile to source control; this ensures the application will use the exact same versions of all dependencies for all developers and when deployed to production. Library packages should not check in the lockfile, though, since they’re expected to work with a range of dependency versions.

If a lockfile already exists, pub get uses the versions of dependencies locked in it if possible. If a dependency isn’t locked, pub gets the latest version of that dependency that satisfies all the version constraints.

like image 198
Fatiha IMOUSSAINE Avatar answered Jan 21 '26 06:01

Fatiha IMOUSSAINE


Seems like uncontrolled version changes and updates on bugfix and minor level.

There should be a command, which just uses the versions described within the lock file.

Otherwise reproduction of an exact version is nearly impossible.

like image 37
Christoph A. B. Avatar answered Jan 21 '26 07:01

Christoph A. B.