Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where does `pub get` download pubspec dependencies to?

Tags:

flutter

dart

In javascript, we have NPM and the node_modules folder in every project. I was not able to find a similar concept for Dart/ Flutter, except the build folder in my app, which contains a folder of a few dependencies I have in pubspec.yaml. It doesn't have any of the source code though, and I think it's actually built from something else. I've also looked in /usr/local/flutter/packages which is where my flutter is installed, but it only shows flutter_driver, flutter_goldens, and more seemingly unrelated folders.

I guess if wanted to read the source code, I really need to find the repo and read from that, or is there a location for dependencies I haven't looked?


I even found projectDir/.dart_tool/pub, which didn't have any of my packages.

like image 200
Ben Butterworth Avatar asked May 06 '20 05:05

Ben Butterworth


People also ask

Where are dart packages stored?

By default, the system package cache is located in the . pub-cache subdirectory of your home directory (on macOS and Linux), or in %LOCALAPPDATA%\Pub\Cache (on Windows; the location might vary depending on the Windows version).

Where is the Pubspec yaml file?

yaml file, often referred to as the pubspec. A basic pubspec is generated when you create a new Flutter project. It's located at the top of the project tree and contains metadata about the project that the Dart and Flutter tooling needs to know.

What is a Pubspec file in dart?

Every pub package needs some metadata so it can specify its dependencies. Pub packages that are shared with others also need to provide some other information so users can discover them. All of this metadata goes in the package's pubspec: a file named pubspec. yaml that's written in the YAML language.


3 Answers

In Android Studio

I could directly view the source code of the package under `

[External Libraries/Dart Packages/Your Packages]

enter image description here `

like image 193
LAW WEI LIANG Avatar answered Nov 19 '22 00:11

LAW WEI LIANG


You can get pubspec downloaded from your flutter sdk location .

/flutter/.pub-cache/hosted/pub.dartlang.org/

You can also clone package git .

like image 33
JustCodeNinja Avatar answered Nov 18 '22 22:11

JustCodeNinja


From the documentation:

Dependencies downloaded over the internet, such as those from Git and the pub.dev site, are stored in a system-wide cache. This means that if multiple packages use the same version of the same dependency, it only needs to be downloaded and stored locally once.

By default, the system package cache is located in the .pub-cache subdirectory of your home directory (on Mac and Linux), or in %APPDATA%\Pub\Cache (on Windows; the location might vary depending on the Windows version). You can configure the location of the cache by setting the PUB_CACHE environment variable before running pub.

So for Mac and Linux for example, this would be ~/.pub-cache/hosted/pub.dartlang.org by default.

like image 21
dumazy Avatar answered Nov 18 '22 22:11

dumazy