is that means that if i use a package version ^2.0.1 that means if the developer of this certain packages update his package to 3.0.0, my application, which including this package will lose it although my application is released?
No, dependencies are only resolved at compile time. Once your application is released, those obviously won't change.
No, if you have ^2.0.1 in your pubspec.yaml and run pub get the most recent version will be locked into pubspec.lock - let's say your dependency has released version 2.0.4 then pubspec.lock will contain that information. For applications it is hence recommended that you add pubspec.lock to your version control. Subsequent pub get will always fetch the locked 2.0.4 until you either change something in your dependencies or run pub upgrade. If you run pub upgrade and the package author has release 2.3.0 this new version will be included. On the other hand if the package author releases 3.0.0 it will still not be used, because ^2.0.1 means the same as >=2.0.1 <3.0.0
Related
I have received this kind error a couple of time before with different packages, usually i just try a combination of different versions till i finally get a match that works. Is there a way to know what package versions are compatible instead of using the trial error approach which is outright time consuming and exhausting.
Initially i though it could be that one of the packages depends on the other, like in this case maybe flutter_svg depends on a different version of flutter_luban so the version in my pubspec clashes with it, but none of these packages depend on one another after viewing the respective package dependencies.
pub get failed (1; So, because sakaHapa depends on both
flutter_svg ^0.17.4 and flutter_luban ^0.1.13, version solving
failed.)
You can use 'pub outdated' command like below.
https://dart.dev/tools/pub/cmd/pub-outdated
Here is column what means.
Current
The version used in your package, as recorded in pubspec.lock. If the package isn’t in pubspec.lock, the value is -.
Upgradable
The latest version allowed by your pubspec.yaml file. This is the version that dart pub upgrade resolves to. The value is - if the value in the Current column is -.
Resolvable
The latest version that can be resolved, when combined with all other dependencies. This version corresponds to what dart pub upgrade gives you if all version constraints in pubspec.yaml are unbounded. A value of - means that the package won’t be needed.
Latest
The latest version of the package available, excluding prereleases unless you use the option --prereleases.
flutter pub outdated
dependencies:
test: ^1.19.3
I had my test dependency purposely downgraded.In my package, test's constraints were ^1.19.3. After I ran dart pub upgrade, it upgraded my test to 1.20.0 and it was visible in pubspec.lock even if my app depended on ^1.19.3 it kept it as it is and ignored it.
This is as intended: the ^ symbol indicates packages up to the next major version (in your example up to version 2.0.0) will upgrade with pub upgrade. If you want to lock to an exact version (not recommended) then you just remove the caret symbol (^).
See here for more details.
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?
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.
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.
I am modifying my default template file from my flutter installation directory here
C:\src\flutter\flutter\packages\flutter_tools\templates\app\pubspec.yaml.tmpl
dependencies:
#omitted
cupertino_icons: ^0.1.3
mobx: latest
flutter_mobx: latest
I am getting this error
Invalid version constraint: Could not parse version "latest". Unknown text at "latest".
How do i get the latest version instead of specifying specific version like ^1.x.x
There is no latest, you have to specify the version number or you can use any:
any
The string any allows any version. This is equivalent to an empty version constraint, but is more explicit. Although any is allowed, we don’t recommend it.
https://dart.dev/tools/pub/dependencies
To update your dependencies to the latest version you can do the following:
Use pub upgrade to update to the latest package versions that your pubspec allows. To identify dependencies in your app or package that aren’t on the latest stable versions, use pub outdated.
try this after the package that you want the latest
http: ^{latest version}
Using Flutter, I am trying to update my dart dependency 2.6.0 but I get an error
Because *project_name* requires SDK version >=2.6.0 <3.0.0, version solving failed.
pub get failed (1)
exit code 1
I want to use the new features that dart offers, such as Extension Methods. How could I go about upgrading my dependency? I have installed the newest stable version of dart on my computer, but regardless I still get that error.
A couple of things that might help:
From this issue, you can try ensuring that you've updated enviroment in your pubspec.yaml file like so:
environment:
sdk: ">=2.0.0-dev.68.0 <3.0.0"
Another thing that might help is just double checking the steps in this post or on the dart installation page to ensure that you've updated to the latest version correctly.