Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between pubspec.lock and pubspec.yaml

Tags:

dart

dart-pub

What is the difference between pubspec.yaml and pubspec.lock? Both are holding the dependencies versions.

like image 209
Hemachandran V K Avatar asked May 21 '26 16:05

Hemachandran V K


1 Answers

The first time you get a new dependency for your package, pub downloads the latest version of it that’s compatible with your other dependencies. It then locks your package to always use that version by creating a lockfile. This is a file named pubspec.lock that pub creates and stores next to your pubspec. It lists the specific versions of each dependency (immediate and transitive) that your package uses.

~ source

In pubspec.yaml there are only packages and versions, which you need to use. In pubspec.lock there are also packages and versions which you need and which each of package that you use needs.

like image 135
Owczar Avatar answered May 23 '26 22:05

Owczar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!