"flutter Pub Get" Can't Get Dependency Plugins
Solution 1:
From yesterday, there is some problem with storage.googleapis.com
in Bangladesh.
First I thought this is maybe an issue with Google's Infrastructure.
But, after some time I realized that it's an issue with BTCL.
To overcome this issue, you can use a VPN tool and re-run your project.
I used Hotspot Sheild VPN
and after that everything was good.
Remember that, the free version limit is 500 MB/Day
I hope this will also work for you.
Solution 2:
'flutter pub get' tries to fetch your plugins that you have declared in your pubspec.yaml and by default it makes a GET request to pub.dev or https://pub.dartlang.org. So if either https://pub.dartlang.org or storage.googleapis.com is blocked by your isp or your company's firewall you wont be able to complete packages get & hence wont be able to build your flutter project. Rather than using the vpn, I prefer using a mirror repository. You can simply change or set two environment varibles with a mirror link like mentioned below. After that 'flutter pub get' command will try to fetch your packages from the specific mirror link. The variables and the links are - * PUB_HOSTED_URL=https://pub.flutter-io.cn * FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
For windows, use these commands in cmd to set the variables in your project environment:
set PUB_HOSTED_URL=https://pub.flutter-io.cn
set FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
Make sure to apply these commands in your project directory in cmd and use 'flutter pub get' from that specific cmd. You can check if the variable is set or not by applying:
echo %PUB_HOSTED_URL%
The output should be the URL that you just set.
These variables are set only for this environment and will be cleared when you close this terminal. So for windows, if you set these variables in your system user environment then you will be able to use 'flutter pub get' and fetch packages from the china mirror sites at any time.
For mac, export the variables in your bash_profile like this:
export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
After this you should be able to apply flutter pub get successfully. (remeber to source your bash_profile after setting a variable)
After all this, if you still can't get the packages: * Delete pubspec.lock file from your project. * Restart your PC. * Check by using echo command to see PUB_HOSTED_URL & FLUTTER_STORAGE_BASE_URL environment variables are set properly or not.
If these variables are set, flutter sdk will try to fetch packages from the mirror site you have set by this variable. If these variables are not present in the workspace environment then flutter sdk will try to fetch the packages using its default urls mentioned earlier.
N.B: When it wasnt working for me, I got frustated and reinstalled flutter sdk and then set these variables in my environment and deleted pubspec.lock file from the project. And Eureka !! It worked for me. After that, with some digging I found out that I didnt have to uninstall & install flutter again.
Hope you will be able to get the packages now without a vpn and anything else. Best of luck.
Solution 3:
- Updating Flutter will not work
- Restarting PC will not work
- Creating new project and running pub get will not work.
If you are from Bangladesh, then only solution is to use VPN for the time being. There are some network issue with BTCL which is causing the issue.
Solution 4:
Just Close the project from IDE and Reopen it. Then Run pub get.
Post a Comment for ""flutter Pub Get" Can't Get Dependency Plugins"