Issue with Pub Get via dart extension in VSCode - flutter

I've got a problem where running pub get via the VSCode dart extension doesn't actually get the packages. It doesn't return an error but if I attempt to build my project, it will just continuously tell me my pubspec lock has updated since I last ran pub get.
Running flutter pub get via terminal solves the issue straight way.
Has anyone else experienced this with VSCode?

You can
delete pubspec.lock
then
flutter clean
Reinstall Extensions

Related

Flutter pub get acting weird

I was trying to do a project I cloned but I cant seem to use any of the packages and when I used the pub get command I get this error
it looks like you edited the pubspec.lock file. pubspec file indent sensitive. you can delete it and run flutter pub get to genarate file again.

How can I fix Flutter_localizations error on the vscode? - Target of URI doesn't exist

I'm trying to use flutter_localizations and I followed this guide
When I save pubspec.yaml on vscode then pub get is ran.
After that vscode can't find app_localizations.dart file.
But this error messages will disappear when I reopen vscode.
Is there anyone with such a problem like me?
Thanks.
Use this command and Open command palette - command + shift + p on the vscode.
Type Dart: Restart Analysis Server and select it.
This error will be gone.
Usually running
flutter gen-l10n
should be enough, however sometimes I'va found myself using
flutter clean && flutter pub get dependencies && flutter packages get
To clean cache, and get the dependencies(which also generate the l10n). 95% of the time the first command should suffice

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

The pubspec.lock file has changed since the .dart_tool/package_config.json file was generated

I'm running a dart only test in intellij and receiving the following error:
The pubspec.lock file has changed since the .dart_tool/package_config.json file was generated, please run "pub get" again.
I have tried pub get a number of times. Any ideas? I'm on the dev branch of Flutter (anything using Dart 2.7 pretty much fails with the same or a similar error message).
Edit
I think that if you have a path reference dependency in the pubspec.yaml file it will fail.
Anything like the following fails with the above message if you try to run a dart test in IntelliJ.
dependencies:
test_dependency:
path: ../test_dependency
I'm not suggesting this is a fix for everyone, but it did resolve my particular situation.
Just ran into this error after upgrading flutter from 1.22.6 to 2.0.2 and trying to use build_runner: ^1.12.2 and json_serializable: ^4.1.0 to generate json serialization/deserialization classes & methods.
The problem is apparently related to the pub package when used with relative paths for packages as noted in the following github issues:
https://github.com/dart-lang/pub/issues/2806
https://github.com/dart-lang/pub/pull/2830
One of the commenters in issue 2806 mentioned running flutter create . inside the flutter project folder which rebuilds .dart_tool/package_config.json, adding any missing entries, solving the problem.
No one solved this problem so far?
I've found a staightforward solution and it works fine for me.
You need to close your IDE (VSCode in my case), make sure that is completely closed using process-monitor.
Then open a terminal window manualy in your project folder and run "flutter pub get"
After that just start your IDE normaly and ewerything will work fine.