32

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:

  • Running flutter packages get
  • Running flutter packages get
  • Restarting my computer
  • Updated flutter
  • Added another package but that did not install either
  • Updated Android Studio

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.

Siddharth Mehra
  • 1,691
  • 1
  • 9
  • 32
Alve
  • 640
  • 2
  • 9
  • 19
  • Why don't you have a version for ```firebase_core```? Is that a copy-paste mistake or your actual pubspec.yaml file? I think that might be your problem (looking at your comments). The current version out there is ```0.3.4```. – tomerpacific Apr 20 '19 at 08:20
  • I think that not specifying the version always gets the latest, but I can try changing it. – Alve Apr 20 '19 at 08:27
  • @tomerpacific Specifying the version did not help. It downloads 0.3.4 during both with and without the version. – Alve Apr 20 '19 at 08:58
  • @Alive - I have two things to suggest : either try starting a fresh new project and only add the desired library and see what happens. Or, have you tried running ```flutter clean```? – tomerpacific Apr 20 '19 at 09:34
  • `flutter clean` did not change anything. Starting a new project did not install the package either. I tried installing the package UUID which I know works but that did not install either. – Alve Apr 20 '19 at 09:44
  • @Alive - without the dynamic theme package, do other packages install successfully? – tomerpacific Apr 20 '19 at 09:55
  • @tomerpacific Removing the dynamic theme package from the dependencies did not allow other packages to be installed. – Alve Apr 20 '19 at 10:07
  • try surrounding double quotes "^1.0.1" – primo Apr 20 '19 at 10:43

21 Answers21

51

Close and open your editor. Worked for me ;)

Sebastián Lara
  • 5,355
  • 2
  • 28
  • 21
42

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.

Tshilidzi Mudau
  • 7,373
  • 6
  • 36
  • 49
Neil Rodriguez
  • 520
  • 4
  • 6
19

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
reza47
  • 650
  • 6
  • 16
9

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.

Usman Khan
  • 3,739
  • 6
  • 41
  • 89
Micah Johns
  • 91
  • 1
  • 3
6

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.

5

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.

Dharman
  • 30,962
  • 25
  • 85
  • 135
Jonas Smith
  • 81
  • 1
  • 5
4

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!

Safi50
  • 379
  • 1
  • 7
3

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.

B.shruti
  • 1,589
  • 1
  • 21
  • 41
2

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.

Alve
  • 640
  • 2
  • 9
  • 19
2

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

rjh500
  • 45
  • 9
1

Try to add ^ to uuid: 2.0.0
Good luck

  // The last version is 
uuid: ^2.0.1 
GirlWhoCode
  • 628
  • 4
  • 12
  • I tried that, it did not change anything but now randomly like 10 attempts of just `flutter packages get -v` it downloaded both uuid and dynamic_theme. – Alve Apr 20 '19 at 10:37
1

in pubspec.yaml click Pub get it work for me

Ahmed Ehab
  • 11
  • 1
  • 2
1

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

1

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.

Victor Eronmosele
  • 7,040
  • 2
  • 10
  • 33
1

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.

Avinash Ch
  • 76
  • 5
1

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
Dharman
  • 30,962
  • 25
  • 85
  • 135
bashizip
  • 562
  • 5
  • 14
1

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

0

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
Mohit Raval
  • 440
  • 1
  • 6
  • 19
0

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.

firozSujan
  • 118
  • 1
  • 9
0

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.

Muhammad Kashif
  • 253
  • 3
  • 6
0

In my case it was happening with a cloned repo from github https://mixable.blog/flutter-generating-g-dart-files-for-json-serialization/

I found the answer on the above link and it helped me sort out the issue