'Where does `pub get` download pubspec dependencies to?

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.



Solution 1:[1]

In Android Studio

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

[External Libraries/Dart Packages/Your Packages]

enter image description here `

Solution 2:[2]

You can get pubspec downloaded from your flutter sdk location .

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

You can also clone package git .

Solution 3:[3]

If you have installed flutter using snap then the location might be

/home/user/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org

Solution 4:[4]

I had forgotten that I've been command + clicking into these libraries all the time in VSCode.

However, it looks like packages are not stored in the app folder. Packages that we use in our projects are downloaded to $FLUTTER_PATH/.pub-cache, so if I'm looking for camera picker plugin, its in

/usr/local/flutter/.pub-cache/hosted/pub.dartlang.org/image_picker-0.6.5+2/lib/image_picker.dart

Solution 5:[5]

If you are running Windows as your OS, you can find the packages under the folder that you installed your Flutter SDK to when setting up Android Studio.

In my case - using Windows 10 - the path is as follows, where C:\ is my primary harddrive and flutter\ the folder containing the Flutter SDK...

C:\flutter\.pub-cache\hosted\pub.dartlang.org\english_words-4.0.0

The above path for instance points to the "english words package", containing the most ~5000 used English words and some utility functions, which are mentioned and used in the Flutter tutorial on their official page for writing and running your first Flutter app.

https://pub.dev/packages/english_words

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 LAW WEI LIANG
Solution 2 JustCodeNinja
Solution 3 Barun Ghosh
Solution 4 Ben Butterworth
Solution 5 themightyhulk