Update Flutter Dependencies In /.Pub-Cache

Flutter is Google’s open-source framework for building natively compiled, multi-platform and beautiful applications from a single update codebase. It means you can design the application for desktop, web and mobile from a single codebase.

It also works well with the existing code, and thus many developers and companies worldwide use the flutter. Moreover, it is completely free to access. But, it is necessary to know the concepts of the flutter in-depth to take the best out of it.

One of the core concepts in flutter is dependencies. A dependency is nothing but another package that your package requires to work. Dependencies are often mentioned in your pubspec.

You can list only immediate dependencies, which the software that your package accessed directly. The pub also handles the transitive dependencies. Keep reading to know in-depth about the flutter dependencies.

Usage of dependencies in the flutter

One of the most important files in any flutter project is the pubspec.yaml file. It is the location where you render all the required dependencies of your flutter project.

Once you know how to use it properly, it helps you in many unexpected ways. It is extremely easy to use the public package in your pubspec.yaml file.

Suppose you want to access the local flutter plugin/package in another flutter application. In such a case, you can refer to the local directory in the pubspec.yaml like mentioned below.

Dependencies:

flutter:

sdk: flutter

my_package:

path: ./my_path/my_package

 

Here, “my_pacakge” is the local package accessed in the local machine.

How to update flutter dependencies in /.pub-cache

Have you erased .pub-cache/hosted/pub.dartlang.org/this_plugin in the folder? Are you looking for the right command to update the dependencies inside pubspec.yaml? Well! You can either get assistance from the reliable Flutter app development company or use the solution mentioned below.

It is usually believed that it is the flutter packages get, and the folder under .pub-cache is not updated yet. Here, you will get a different solution for your problem. You can use any one of them suitable for your needs.

Solution 1

Run the following command:

flutter pub cache repair or delete /Users/xxxxxxx/development/tools/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-0.8.2+3/

And then, run flutter packages again.

Ensure you have a fast internet connection and are ready to lose one hour of the productive hours before running this command. It will re-download all the packages installed on your PC. It means all the versions of every package are downloaded again.

If the command fails to delete the cache folder, check the updated version in the lock file. In some cases, the lock renders problems with updating the version number. So, you should be careful to avoid hassles.

Solution 2

You can remove the package from dependencies in pubspec.yaml. Then, you can run the flutter packages. After that, you can add the package to the dependencies again and run flutter packages.

In many cases, this process will sort out the problem immediately. However, even after trying several times, do you still encounter the same issue? If yes, then you can go with other solutions mentioned here.

Solution 3

You can make use of the following steps to sort out the problem immediately. These steps work well for many people.

Flutter installation corrupted 

Remember that the flutter install directory is in an inconsistent state, and thus it often throws various troubles. Therefore, whenever the installation directory is corrupted, you should take immediate action. Or else, you will confront more issues.

Causes

As said earlier, the flutter install directory is not in a good state, and thus it is quite impossible to find the cause behind the problem. So, the cause of the problem is often unclear.

Different ways to fix

You can run the following commands in the flutter install directory to fix the issues immediately.

 

git clean -xfd

git stash save –keep-index

git stash drop

git pull

flutter doctor

 

Now, you will get relief from the flutter installation corruption issues.

Corrupted cache

The package in the pub cache is corrupted many times. It is especially within the plugin packages.

Symptoms

The major symptom of this problem is getting syntax errors at build time about code in dependencies.

Causes

In many cases, the cause of the problem is unknown. So, instead of finding the cause, you can use the right solution to fix the error immediately.

Developers often use IDEs or editors, but it does not prevent editing plugin files. So, whenever they navigate into plugin code, they may accidentally modify/change the code.

Ways to fix

Run flutter pub cache repair

It may take some time because it re-downloads every package in the cache. It also includes the outdated versions that are not accessed anymore by any project on disk.

Delete ~/.pub-cache/hosted and/or ~/.pub-cache/git (for Git dependencies).

Then, you have to delete a specific package or package version. Now, you should look for the exact path in the cache for a specific package especially in the .packages file of your project.

For instance,

for firebase_auth

Solution 4

In many cases, clearing the project’s cache will help you. Are you wondering how it is possible? Yes! You can empty the whole project’s cache to reclaim the extra disk space. Or, you can do it to remove the problematic packages. It fixes the issues quickly. Run the following command to clear the project cache.

flutter pub cache clean

Solution 5

This solution is extremely simple and easy to follow. As a result, many developers have obtained the desired solution with this command.

At first, delete the pubspec.lock file

After that, run the command flutter pub get again

Conclusion

Now, you will understand the dependencies in flutter and how to update the dependencies in /.pub-cache. You can use any of the solutions mentioned above to meet your demands. If you still have any doubt, you can hire Flutter developers for expert consultation & support. The expert flutter professional will give you enough guidance to sort out the problem and help you to complete your flutter project.

About Ambika Taylor

Myself Ambika Taylor. I am admin of https://hammburg.com/. For any business query, you can contact me at [email protected]