Update flutter dependencies in /.pub-cache

FlutterFlutter DependenciesFlutter Plugin

Flutter Problem Overview


I erased in my folder .pub-cache/hosted/pub.dartlang.org/this_plugin

What is the command to update the dependencies inside pubsec.yaml? I believe it is

> flutter packages get

The folder under .pub-cache is still not up to date.

Note: there was a pubspec.lock that I deleted

Flutter Solutions


Solution 1 - Flutter

> Disclaimer: By running the command below, have a really fast internet > connection or be ready to lose one hour of productive hours. ( it will > redownload every package every installed on your pc, and I mean each > and all of the versions of each packages)~TSR

flutter pub cache repair 

or delete /Users/xxxxxxx/development/tools/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-0.8.2+3/ and run flutter packages get again.

if all the above things fail delete the cache folder or also check the version updated in the lock file (some time lock give me the problem with updating the version number)

PS: Why flutter pub cache repair download every package version previously used?

Solution 2 - Flutter

Remove the package from dependencies in pubspec.yaml, run flutter packages get. And then add the package to dependencies again and running flutter packages get.This process has solved the problem for me in the past.

Solution 3 - Flutter

This steps worked for me

Delete the pubspec.lock file then run the command flutter pub get again.

Solution 4 - Flutter

The below steps worked for me.

Flutter installation corrupted
The Flutter install directory is in an inconsistent state and that causes all kinds of troubles.

Causes
Unclear

Ways to fix
Run the following commands in the Flutter install directory:

git clean -xfd
git stash save --keep-index
git stash drop
git pull
flutter doctor

Corrupted cache
Especially with plugin packages, it was seen several times that the package in the pub cache was corrupted.

Symptoms
Usually syntax errors at build time about code in dependencies.

Causes
Unknown.
IDEs or editors used by developers might not prevent editing plugin files and when they navigate into plugin code they might accidentally modify the code.

Ways to fix

Run flutter pub cache repair
This might take quite some time and re-downloads every package in the cache, even outdated versions that might not be used anymore by any project on disk.

Delete ~/.pub-cache/hosted and/or ~/.pub-cache/git (for Git dependencies). This requires running flutter packages to get in all active projects on your machine afterward.

Delete a specific package or package version. Look up the exact path in the cache for a specific package in the .packages file of your project. For example for firebase_auth

Reference: https://github.com/flutter/flutter/wiki/Workarounds-for-common-issues#flutter-installation-corrupted

Solution 5 - Flutter

Clearing the projects cache

You can empty the entire projects cache to reclaim extra disk space or remove problematic packages:

flutter pub cache clean

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionRaymond ChenonView Question on Stackoverflow
Solution 1 - FlutterLOG_TAGView Answer on Stackoverflow
Solution 2 - FlutterMazin IbrahimView Answer on Stackoverflow
Solution 3 - FlutterJengifyView Answer on Stackoverflow
Solution 4 - FlutterVijayendra MudigalView Answer on Stackoverflow
Solution 5 - FlutterAgoo ClintonView Answer on Stackoverflow