Alve
Alve

Reputation: 740

Flutter packages get does not install new package

I'm trying to install a package (dynamic_theme) in flutter. When I run flutter packages get -v it does not even try to install the package.

So far I've tried:

In my pubspec.yaml I've put:

dependencies:
  flutter:
    sdk: flutter
  firebase_core:
  cupertino_icons: ^0.1.2
  dynamic_theme: ^1.0.1 # the package does not install
  uuid: 2.0.0 # the package does not install

In the logs for the verbose run of flutter packages get where it installs the packages it outputs:

[ +422 ms] Running "flutter packages get" in quiz_app... (completed in 0.4s)
[  +57 ms] Found plugin firebase_core at E:\Other\SDKs\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_core-0.3.4\
[  +13 ms] Found plugin shared_preferences at E:\Other\SDKs\flutter\.pub-cache\hosted\pub.dartlang.org\shared_preferences-0.5.2\
[ +141 ms] Found plugin firebase_core at E:\Other\SDKs\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_core-0.3.4\
[   +6 ms] Found plugin shared_preferences at E:\Other\SDKs\flutter\.pub-cache\hosted\pub.dartlang.org\shared_preferences-0.5.2\
[  +26 ms] "flutter get" took 718ms.

I expected that flutter downloaded and installed the packages, but it does just check for updates on the already installed packages like firebase_core.

Upvotes: 39

Views: 113904

Answers (21)

maxmitz
maxmitz

Reputation: 180

This worked for me:

  1. Deleting .pub-cache folder this directory is located under $HOME/.pub-cache (on macOS and Linux), or in %LOCALAPPDATA%\Pub\Cache (on Windows)
  2. flutter pub clean
  3. flutter pub get

Upvotes: 1

Abdelkhalek Haddany
Abdelkhalek Haddany

Reputation: 463

in pubspec.yml be sure you add your packages under dependencies not dev_dependencies

Upvotes: 1

B.shruti
B.shruti

Reputation: 1630

If anyone of you is using Android Studio then Going to File->Invalidate Caches/Restart is your friend.

This is what has helped me, getting the updated dependencies for Android Studio.

Upvotes: 3

Safi50
Safi50

Reputation: 361

If you delete a package from External Libraries > Dart Packages, you need to run --> flutter pub cache repair This will reinstall all the external libraries and update the missing ones. Get dependencies or Pub get and you are good to go!

Upvotes: 4

Jonas Smith
Jonas Smith

Reputation: 101

In Visual studio code, the thing that fixed it for me was

Command+Shift+P and then search "Dart: restart analysis server", in the pop up bar.

after the analysis was finished it worked like a charm.

Upvotes: 7

bashizip
bashizip

Reputation: 581

I fixed this issue by accepting Android Licenses using flutter doctor --android licenses. Note that you must install android SDK command-line tools to make this command work.

Steps:

  • Install command-line tools via SDK manager
  • Accept android licenses
  • Run flutter pub get

Upvotes: 1

Avinash Ch
Avinash Ch

Reputation: 86

I hit flutter pub get . Though it ended with exit code 0 , i couldnt access my dependency lib classes via intellicense.

I restarted Android studio with Invalidate & Restart. That fixed the issue for me.

Upvotes: 2

rjh500
rjh500

Reputation: 55

I had the same issue when I had my project in my google drive folder which has a space in the path. I moved it to the android studio folder and then pub get worked fine

Upvotes: 2

Neil Rodriguez
Neil Rodriguez

Reputation: 580

so basically run:

flutter clean

flutter packages get

flutter packages upgrade

Restart Android Studio or Visual Studio

you can restart VSC by:

ctrl + shift + P and then a search bar will appear and then type: "restart" and smash the Enter key.

Upvotes: 48

Victor Eronmosele
Victor Eronmosele

Reputation: 7716

If you moved your project files from to a newly created project (probably because of AndroidX migration), check that your new pubspec.yaml is the same as the previous one or your code will blow up with package errors.

Upvotes: 1

reza47
reza47

Reputation: 795

hi I have a similar problem I deleted a package from the dart packages folder and when I run flutter pub run it won't download and work so I tried all the way people said but something worked for me is I tried to repairing pub cache and it worked just run

flutter pub cache repair

Upvotes: 24

Muhammad Kashif
Muhammad Kashif

Reputation: 331

in my case nothing has happened after flutter upgrade, clean, pub get, etc. but when I restart my project it automatically gets pub Packages in VS code.

in a menu bar, Run => start debugging.

Upvotes: 0

firozSujan
firozSujan

Reputation: 126

After the update (23 September 2020) of Android Studio 4.1 the builtin terminal is not working for getting new packages. Solution: Run the command prompt in Administrator mode. Go to your project directory and run command flutter clean after that run flutter pub get.

Upvotes: 0

Mohit Raval
Mohit Raval

Reputation: 438

Some quick fix for Android Studio :

  1. Check proper space before package name ( very much important )
  1. Click on Pub get or from terminal run command flutter packages get , and you can download these dependencies, After successfully downloading the package, This warning is just here to reminds you that your dependencies aren't downloaded => Click on Get Dependencies of the first warning

If you still getting error then follow below steps:

  1. Clean App : Android Studio > Tools > Flutter > Flutter Clean
  2. Restart Android Studio

Upvotes: 0

Ayan Bhattacharjee
Ayan Bhattacharjee

Reputation: 515

If you are using IntelliJ or Android Studio, do the following:

  • flutter clean

  • flutter packages get

and then click on File -> Invalidate Caches / Restart

After the IDE restarts chances are you may still face error but this time when you hover the code the import library tooltip will show

Upvotes: 1

Shahryar Rafique
Shahryar Rafique

Reputation: 123

To install package you have to press double enter after the dependencies: flutter: sdk: flutter carousel_pro: ^1.0.0 Then Package name e.g: carousel_pro: ^1.0.0. Enter,spaces, and back spaces matter in pubspec.yaml File. I hope this resolve the issue.

Upvotes: 6

Ahmed Ehab
Ahmed Ehab

Reputation: 31

in pubspec.yaml click Pub get it work for me

Upvotes: 2

Micah Johns
Micah Johns

Reputation: 91

I am currently experiencing this situation. When looking into it deeper, I've found that the packages never actually install themselves into the flutter packages folder.

The response I'm getting is exit code 0, with no error actual being reported.

When I put in my import 'package:english_words/english_words.dart'; it just shows up as a problem.

Upvotes: 9

Sebastián Lara
Sebastián Lara

Reputation: 5551

Close and open your editor. Worked for me ;)

Upvotes: 62

Alve
Alve

Reputation: 740

Something solved it randomly. I did not do anything but try multiple times. After some 10 attempts it downloaded and installed both uuid and dynamic_theme.

Upvotes: 2

GirlWhoCode
GirlWhoCode

Reputation: 628

Try to add ^ to uuid: 2.0.0
Good luck

  // The last version is 
uuid: ^2.0.1 

Upvotes: 1

Related Questions