After using the Flutter Clean command, packages cannot be found and too many errors appear.
After running the "flutter pub get" command, the problems are corrected.
It wasn't like this before, what could be the reason for this?
Flutter 2.0.2 • channel stable •
Framework • revision 8962f6dc68 (6 days ago) • 2021-03-11 13:22:20 -0800
Engine • revision 5d8bf811b3
Tools • Dart 2.12.1
Flutter clean removes all cached packages which your IDE depends on for code completion. So that is why after running flutter pub get everything goes back to normal as the command re-downloads all the package files the IDE depends on.
Just run flutter pub get after flutter clean Command.
By doing that dependencies on pubspec.yaml file will be updated as well as flutter and dark SDK dependencies.
Why is it like this, a little confused?
Related
I see that in the pubspec the Dart SDK version is specified/constrained but is there anywhere to specify the Flutter SDK version? Maybe I'm missing something obvious but coming from other tech stacks like Java/Gradle I believe normally SDK versions are explicit?
What got me thinking about this is that I'm using Codemagic and have my Flutter version at "default" but I can't even tell what that is from their docs or their build logs.
You can get that from your terminal just run flutter --version, this will print out your current flutter SDK and dart SDK versions.
flutter --version
the result should be similar to this
Flutter 3.7.0 • channel stable • https://github.com/flutter/flutter.git
Framework • revision b06b8b2710 (2 weeks ago) • 2023-01-23 16:55:55 -0800
Engine • revision b24591ed32
Tools • Dart 2.19.0 • DevTools 2.20.1
Look like it's easy to limit it like this - I just missed it in the doc.
If I say I need ^4.0.0 then I get a meaningful error:
environment:
sdk: '>=2.18.6 <3.0.0'
flutter: ^4.0.0
Running "flutter pub get" in XXXX... Resolving
dependencies... The current Flutter SDK version is 3.7.1.
Because XXXX requires Flutter SDK version >=4.0.0, version
solving failed. pub get failed command:
"/opt/homebrew/Caskroom/flutter/3.3.10/flutter/bin/cache/dart-sdk/bin/dart
__deprecated_pub --directory . get --example" pub env: { "FLUTTER_ROOT": "/opt/homebrew/Caskroom/flutter/3.3.10/flutter",
"PUB_ENVIRONMENT": "flutter_cli:get", "PUB_CACHE":
"/Users/DENNCH3/.pub-cache", } exit code: 1
I'm trying to upgrade Flutter version in my project from 2.8.0 to 3.7.0. If I got it right flutter should be using the default version installed on my machine, but it doesn't. See commands below.
flutter --version
Flutter 3.7.3 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 9944297138 (4 days ago) • 2023-02-08 15:46:04 -0800
Engine • revision 248290d6d5
Tools • Dart 2.19.2 • DevTools 2.20.1
Still it tries to use previous version
flutter pub get
Running "flutter pub get" in xxx...
Resolving dependencies...
Because xxx depends on flutter >=3.0.0 which doesn't match any versions, version solving failed.
pub get failed
command: "/usr/local/Caskroom/flutter/2.8.0/flutter/bin/cache/dart-sdk/bin/dart __deprecated_pub --color
--directory . get --example"
pub env: {
"FLUTTER_ROOT": "/usr/local/Caskroom/flutter/2.8.0/flutter",
"PUB_ENVIRONMENT": "flutter_cli:get",
"PUB_CACHE": "/Users/yyy/.pub-cache",
}
exit code: 1
you could try :
flutter clean
flutter pub get
if it repeats, maybe you could:
flutter clean
flutter pub upgrade
i am using flutter:
Flutter 1.20.0 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 840c9205b3 (6 months ago) • 2020-08-04 20:55:12 -0700
Engine • revision c8e3b94853
Tools • Dart 2.9.0
the main reason i am still using Flutter 1.20.0 is my own question i asked here also:
is it possible to continue using flutter SDK "1.20.0" and not upgrading anymore? any future problems can arise from that behavior?
till yesterday everything was working well...today i am trying to open devtools in VScode but i keep getting this:
VScode cannot connect
i tried:
flutter pub global deactivate devtools
flutter pub global activate devtools
flutter pub global run devtools
but nothing changes
i tried:
flutter pub cache repair
it reinstalled all my project packages....
and i tried
pub clean it deleted all previous builds
when i try to run App with flutter run --observatory-port=9200
and i take the URL from the logcat and paste it in the devtools to connect to the current working App..i get this:
chrome devtools cannot connect
i am able to run devtools in Android studio successfully with Flutter Inspector...why i am not able to use devtools in VScode!!!
This was a bug in a recent release of DevTools that didn't gracefully handle versions of Flutter that were missing a new API:
https://github.com/flutter/devtools/issues/2648
This bug was fixed in version 0.9.7+2 of DevTools, which VS Code should automatically update to. If it doesn't, you can manually update with:
pub global activate devtools
Note: do not include a flutter prefix.
If pub isn't in your PATH you may need to run it with a full path like:
(flutter SDK)\bin\cache\dart-sdk\bin\pub global activate devtools
Presently on the master channel, I switched to the beta channel then I run flutter upgrade to find out I can't use Linux as a device, so I switched back to the master branch, I run flutter upgrade. Then I started getting these errors:
Because flutter_tools depends on collection >=1.15.0-nnbd <1.15.0-nullsafety.2
which requires SDK version >=2.9.0-18.0 <=2.9.10, version solving failed.
Error: Unable to 'pub upgrade' flutter tool. Retrying in five seconds... (9 tries left)
The current Dart SDK version is 2.10.0-0.0.dev.flutter-a3815b6590.
Flutter Info before switching to the master channel
Flutter 1.18.0-11.1.pre • channel beta • https://github.com/flutter/flutter.git
Framework • revision 2738a11 (3 months ago) • 2020-05-13 15:24:36 -0700
Engine • revision ef9215ceb2
Tools • Dart 2.9.0 (build 2.9.0-8.2.beta)
I can't presently get any info on the master channel (which I am presently on) cause every time I run any flutter command, it tries to run pub upgrade with keeps giving error.
I am assuming the issue is that Dart SDK
upgraded, if I can roll back to a version compatible with the dependency it should work, or the dependency should be reviewed.
Fixed.
I used git to switched branch to stable, then I run flutter upgrade, it worked fine, but I need to run a Linux app on flutter, so I used git to switch branch to dev, then run flutter upgrade again.
What settings to disable to make it fast again?
I'm using VSCode for flutter development. Now very slow when starting the app and during hot reload. Now almost impossible to perform hot reload. I must stop it, do changes then start rather than waiting on hot reload process.
Before update, it was fast but sometimes crash.
I only use Dart 2.21.1 and Flutter 2.21.1 extension. And running on Windows 10.
=======================================================================
The issue seems gone away.
Now I'm using VS Code 1.31.1
flutter --version
Flutter 1.1.8 • channel beta • https://github.com/flutter/flutter.git
Framework • revision 985ccb6d14 (8 weeks ago) • 2019-01-08 13:45:55 -0800
Engine • revision 7112b72cc2
Tools • Dart 2.1.1 (build 2.1.1-dev.0.1 ec86471ccc)
And Dart/Flutter extension is 2.24.0
In your folder, run
flutter clean
this will delete all flutter dependencies and then re-create the project again by using
flutter create YourProjectName
this will create all the flutter dependencies again in your current project, you will not loose your files
The issue seems gone away.
Now I'm using VS Code 1.31.1
flutter --version
Flutter 1.1.8 • channel beta • https://github.com/flutter/flutter.git
Framework • revision 985ccb6d14 (8 weeks ago) • 2019-01-08 13:45:55 -0800
Engine • revision 7112b72cc2
Tools • Dart 2.1.1 (build 2.1.1-dev.0.1 ec86471ccc)
And Dart/Flutter extension is 2.24.0