As the image show, there are several versions of same pubs in my local:
.pub-cache/hosted/pub.dartlang.org/some-version1.
.pub-cache/hosted/pub.dartlang.org/some-version2.
.pub-cache/hosted/pub.dartlang.org/some-version3.
.pub-cache/hosted/pub.dartlang.org/some-version4.
Is there a way to clean them ?
Or clean them by provide a minimal dart version. (like mini dart > 2.6.0) ?
I don't think there is a command for that. Because pub cannot know whether you have an old project lying around that depends on one of these older package versions or not.
The easiest way to clean away old packages is to just delete .pub-cache altogether. When you first run flutter pub get the ones that you actually use will be re-downloaded. This would get rid of the unused ones.
flutter 1.17 provided a new commend: flutter pub outdated. which have good progress on this.
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 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 created a package that is a collection of my own helper classes for faster developing...
The package also included firebase_analytics: which requires a native implementation for each platform i want it to run. Even if i dont wanted to use firebase at all, but still wanted to use my package i was forced to create firebase-config files for the app, because the app crashes if the firebase_analytics package does not find a valid file for the specific platform. To avoid those things i splitted my package in two packages.
The Core-Package: All helper classes that run native dart code
Optional extension: Only the classes that need the firebase implementation
So if i want to use the package without firebase i just have to depend on the core.
If i want to use the firebase variant i could simply depend the firebase package, because the extension package itself depends on the core-package in its own pubspec.yaml file.
PROBLEM: Since i restructured my package like i described, all my apps that depend on it are not building anymore. The console says that all packages that i depend on in my two packages can not be found. This error occures both ways: With firebase & without.
ERROR: (Scroll down for the complete console output)
MY ATTEMPTS:
"flutter clean" & "flutter pub get" in every package and app folder
"flutter pub cache repair"
CORE-PACKAGE Pubspec.yaml:
FIREBASE-Extension Pubspec.yaml:
Plain Console Output:
pastebin.com/m14cbqDV
Thanks for any help!!
I am facing the same issue while i was making a build in Xcode 13.So I had upgraded my flutter version 2.8.0 to 2.10.2 and also removed the version of all firebase dependencies, then the issue was finally solved.
I have faced similar issues and resolved them by removing package versions. Issues like this often arise due to mismatched versions of packages (eg firebase_core, firebase analytics). Please try to remove versions of the firebase packages or the whole packages. (like firebase_analytics :).
Sorry, my bad! As you can see i moved my dependencys to the dev section of my pubspec.yaml. They should be placed in the dependency section.
Hello I tried to upgrade in_app_purchase 0.3.4+8 package, so that created some bugs due to somes changes. So I downgrade to return to a fonctionnal version but now it's not working... I only downgrade but it's like a modification in cache or other. How can I fix it ?
I try remove pubspeck.lock and flutter pub cache repair but no change
Thank tou
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.
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.