Reputation: 155
I have been using flutter pub get
for updating pubspect.yaml
Now I have found that there is a similar command dart pub get
What are the differences between these two commands?
Upvotes: 4
Views: 3223
Reputation: 1060
Using the command flutter pub get
you are getting dart packages for Flutter.
Using dart pub get
you are getting Dart packages.
You can create dart projects without Flutter and there you’ll need use the command dart pub get
.
Every Flutter project is a Dart project but not every Dart project is a Flutter project, because Flutter is a UI kit or framework for building UIs in the Dart programming language.
Upvotes: 6
Reputation: 4750
When dart 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, dart 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. This is the primary difference between dart pub get
and dart pub upgrade
, which always tries to get the latest versions of all dependencies.
When running flutter pub get
(Packages get in IntelliJ or Android Studio) for the first time after adding a package, Flutter saves the concrete package version found in the pubspec.lock
lockfile. This ensures that you get the same version again if you, or another developer on your team, run flutter pub get
.
Upvotes: 0