When I try to run my flutter code in VS code it gives following error: The current Dart SDK version is 3.1.0.
Because learning requires SDK version ^3.5.4, version solving failed.
You can try the following suggestion to make the pubspec resolve:
I was trying to run a flutter app in my physical device. I expected the app to be installed and run on my mobile to be tested but VS code throws the error(worked in cmd)
This issue typically happens if VS Code and Command Prompt are pointing to different Flutter SDK paths.
Check and Verify Flutter SDK in VS Code:
In VS Code, open the Command Palette (View > Command Palette), type "Flutter: Change SDK", and choose the correct Flutter path to match the version in CMD.
Update Environment Variables:
Ensure only the correct Flutter SDK path is in your system’s PATH. Remove if any duplicate or outdated paths found:
Confirm Flutter sdk Version:
Run flutter --version in both CMD and the VS Code terminal to verify they’re using the same SDK at both.