'flutter pub get' does not work in VSCode - flutter

I'm currently developing flutter application with VSCode and want to add some packages. ex) dropdown_menu
I did flutter pub get / flutter packages get / clicking down arrow button in vscode(get Packages)
and this is all I get everytime
PS D:\VSCodeProjects\testt> flutter pub get
Running "flutter pub get" in testt... 0.4s
PS D:\VSCodeProjects\testt>
this is my code in pubspec.
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^0.1.3
dropdown_menu: ^1.1.0
I did turn on / off program( and computer) , restart,
and
flutter clean
flutter packages get
flutter packages upgrade
Does anybody know how to solve??

It's running, by default in vs code whenever you save your .yaml file it runs it under the hood. When you explicitly run it using the command, it takes very less time as the packages are already up to date.
If in doubt, try to use the new packages that you added and they should not give errors.

flutter pub get is meant to be quick especially when you don't have much libraries.
What you see is right there should not be any problem.
But if there is issues where you are going for a specific version and it is not working, this is because pubspec.yaml stores the settings of what version of library but pubspec.lock stores the actual version your app is using.
Judging from your comments of it not showing up. It might be related to this #31115
try the solution and see if it works.

Select the View > Command Palette menubar option
Type "flutter"
Click "flutter get packages"

you can use this in vscode
Pubspec Assist

After typing the package don't forget to save the yaml file or click ctrl + s.

Related

How to update pubspec.yaml on flutter pub upgrade automatically?

Coming from npm, I deeply dislike the way Google handles package updates within Flutter. Instead of updating the pubspec.yaml on flutter pub upgrade, it will only update the pubspec.lock.
To ensure that the pubspec.yaml is up to date, I have to run flutter pub outdated and manually adjust the pubspec.yaml before running flutter pub upgrade. I'm too lazy for that, it's no fun, I want this to be automated. The recommend versions of flutter pub outdated should be set in the pubspec.yaml for me.
How to I do that?
you can use Ctrl+Space after a package name in pubspec.yaml to get the latest version.
you must press Ctrl+Space exactly one space after ' : ' to see the latest version.
cupertino_icons: <click Ctrl+Space here>

Flutter clean command causes null safety errors

Ever since null-safety was introduced to Flutter, when I do flutter clean, the whole project switches to null-safety.
I can not update my whole project to null-safety quite yet as many packages I use have not migrated.
How can I do a flutter clean without getting thousands of errors telling me that non-nullable item must be initialized first...
I am currently on Flutter 1.24.0-10.2-pre, channel beta.
pubspec.yaml includes the following
environment:
sdk: ">=2.2.2 <3.0.0"
I get exactly the same issue. I haven't found a fix yet but if you open the pub spec.yaml file and save it without making changes it solves the issue until you next run flutter clean.
I have the same issue. For me running flutter pub get worked. But I still don't know why this error happens
Using VS code editor:
Go to terminal
Execute flutter pub get
The above fixed similar issue I got
I have the same problem, For me
Go To 'Terminal'
Type 'flutter pub get'
That is!!
I am using VS code.
Sometimes you have to run this command:
dart pub upgrade
or
dart pub update
If you get an error after running "flutter clean", do the following to solve the problem;
Go to your terminal
Run this command: "flutter pub get"
After this you'll see "Running 'flutter pub get' in 'xxx'(where xxx stands for the name of your project)
When this is complete, all will be reset back to normal

I cannot seem to download/install the carousel_slider package through pubspec.yaml

i have ran flutter pub get multiple times but I'm still not able to download the carousel_slider package
So far I've tried:
Running flutter clean
Running flutter packages get
Running flutter packages get
Restarting my computer
Updated flutter
Tried opening it in VSCode instead
Added another package (but that did install, I could see it in the Dart Packages)
I see that is working well, but you can try deleting the pubspect.lock
In the terminal write this commands:
flutter clean
flutter packages get

flutter pub outdated for a specific package?

When I run
flutter pub outdated
it gives me a list of all the packages I have in pubspec.yaml which are outdated. What if I have more than 100 packages in it, I'd like to know is there any command or way (except searching in terminal) to find out the information provided by above command but only for that package, something like:
flutter pub outdated xyz
where xyz is my package.
For Android Studio and IntelliJ, use Flutter pub version checker
For Visual Studio Code, use Pubspec assist
There is this plugin for Android Studio called Flutter enhancement suite which automatically detects outdated packages and suggests updates for you inside pubspec.yaml file

how to add external package to flutter with visual studio code

the doc reference android studio, but I'm using Visual Studio Code, so how do I do this?
"While viewing the pubspec in Android Studio’s editor view, click Packages get upper right."
in pubspec.yaml I added "english_words: ^3.1.0", and I ran 'flutter packages get' from the command palette but it's not working.
make sure you are saving the file before running flutter packages get
I was having error on mine too. This was my initial code
dependencies:
flutter:
sdk: flutter
http: ^0.12.2
and I got this error
"Error on line 25, column 5 of pubspec.yaml: A dependency may only have one source."
so I adjusted my indentation like so
dependencies:
flutter:
sdk: flutter
http: ^0.12.2
And it worked just fined
HOW TO ADD EXTERNAL PACKAGE TO DART AND FLUTTER WITH VISUAL STUDIO CODE
The final solution to this problem is here
you will get the latest version of whatever package you are looking for
Forget going to the pub.dev to search for your packages and copy the dependency
text.
THE SOLUTION IS:
Install the "pubspec assist" by Jeroen Meijer in the extension menu.
Open the pubspec.yaml file in the vs code.
Simply open the Command Palette (by default, Ctrl+Shift+P on Windows, ⌘+Shift+P
on Mac) and search for "Pubspec Assist" and press ENTER.
Then search for the required package with their names. It will automatically add
the dependencies to the pubspec.yaml file. After that save the file using
Ctrl+S.
Get ready to import the package in the main file.