Dart: How to determine which pub package is discontinued?
I have a long list of packages. When I run dart pub upgrade it says that one is discontinued. Is there a command to list which one is discontinued?
Use the following combination of commands:
dart pub upgrade --dry-run | grep discontinued
In the resulting long list of packages from the dart pub upgrade command, I did not at first notice that "discontinued" is printed in parenthesis inline with the corresponding package. The above command combo will find those lines for you.
It's possible that the discontinued package is not in your direct pubspec packages, but buried deep in their dependencies. In my case, the "pedantic" package is discontinued, and that is still used by many other packages.
[EDIT]
In my original answer, I mixed up and put the incorrect command, which one of the comments references. "outdated" does not return discontinued. I corrected the command above. This was my original incorrect command.
dart pub outdated | grep discontinued
Related
I can add a package to my pubspec.yaml file from command line using:
dart pub add foo
But how to add multiple packages?
dart pub add foo, bar // Doesn't work
Right now (Dart 2.15.1), the Dart pub tool does not support adding multiple package dependencies in one command. You therefore need to run pub add for each package you want to add as dependency for your project.
A pull request for pub have recently being merged which adds support for adding multiple dependencies in one operation.
You can find the issue here: https://github.com/dart-lang/pub/issues/3273
And pull request here: https://github.com/dart-lang/pub/pull/3283
Since this has happen rather recent, my own personal guess is, that this change is not going to be part of Dart 2.16 but rather Dart 2.17, since 2.16 has been closed for further development for some time to make it ready for release in the near future.
In bash:
for pkg in redux flutter_redux redux_sagas do; flutter pub add $pkg; done;
Obv add more packages as desired, space separated.
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
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.
Lets say I am starting a new dart project. I have a few packages on pub.dev I know that I want to use, and I want to use the most recent version of these packages.
Right now, I open my browser and go to pub.dev and find each package, then check the Versions or Installing tab to find out what the latest version is so I can put that in my pubspec.yaml. Then I can run pub get
Using npm, you can run npm install <package> and npm will automatically fetch the latest version of the package and add it to package.json
Is there a pub command, syntax for pubspec.yaml, or something else that will make pub resolve the latest version of a package and use it in my project, without having to manually look up the latest version?
Normally in Flutter, the packages which you want to use need to be added to pubspec.yaml and run pub get. But there are also some IDE plugins like npm.
For example, Pubspec Assist is using on Visual Studio, you can add or update your dependencies without going pub.dev. But you have to know which packages do you want to use at least for a time.
https://marketplace.visualstudio.com/items?itemName=jeroen-meijer.pubspec-assist
Simply enter the following command in the terminal
flutter pub add provider
Of course, where it says provider, put the package you want to install.
The package with the latest version is automatically added to your pubspec.yaml.
Otherwise you can always do what #jamesdlin said and leave the version field empty.
When I run
flutter pub outdated
it gives me a list of all the packages I have in pubspec.yaml which are outdated. What if I have more than 100 packages in it, I'd like to know is there any command or way (except searching in terminal) to find out the information provided by above command but only for that package, something like:
flutter pub outdated xyz
where xyz is my package.
For Android Studio and IntelliJ, use Flutter pub version checker
For Visual Studio Code, use Pubspec assist
There is this plugin for Android Studio called Flutter enhancement suite which automatically detects outdated packages and suggests updates for you inside pubspec.yaml file