Ben Winding
Ben Winding

Reputation: 11787

Flutter: Can I force flutter to install packages from pubspec.lock?

Does anyone know if you can do reproducible builds in Flutter? There doesn't seem to be an option to install from the pubspec.lock file. I would of expected something like:

flutter pub get --from-lockfile

The problem is that the pubspec.lock is modified on every run of flutter pub get so I can't easily go back to the previous state of the dependencies at different points in the git history.

I would of expected it to behave like the yarn.lock or package-lock.json which allow you to create reproducible builds of the project.

Upvotes: 5

Views: 4257

Answers (2)

If you mean that you want it to install with respect the content of pubspec.lock, then you have to run the following command:

flutter pub get --offline

Note: Make sure that you already have a pubspec.lock file.

Upvotes: 0

Omatt
Omatt

Reputation: 10473

As mentioned in the doc, pub get should fetch what's in pubspec.lock if the lockfile contains the solution for the dependency requirements and constraints configured in pubspec.yaml. Simply put, if pubspec.yaml and pubspec.lock isn't modified, and neither Dart nor Flutter SDK is upgraded, then pub get should fetch what's listed in pubspec.lock.

If you're still having issues and can be reproducible, you can file an issue here https://github.com/dart-lang/pub/issues - as jonasfj also mentioned in the Comments.

Upvotes: 2

Related Questions