[英]vscode not select correct dart sdk
找到了解決方案,如果沒有,則在根項目文件夾中創建.vscode
文件夾。
接下來創建settings.json
如果沒有。 粘貼下面的 json 以覆蓋當前項目 sdk 路徑。 記得替換成自己的sdk路徑
{
"dart.flutterSdkPath": "C:\\flutter_1.22.6",
"dart.sdkPath": "C:\\dart\\dart-sdk_2.7.0"
}
無需每次使用Ctrl + Shift + P更改 sdk 路徑。
在這里提示,如果在構建時遇到任何 pub 緩存問題,只需flutter clean
和flutter pub get
你可以試試這個,並創建一個launch.json,通過在VScode菜單中運行,然后添加配置,
請注意,添加以下項目目錄。
{
"configurations": [
{
"program": "lib/main.dart",
"name": "YOUR APP NAME",
"cwd": "/home/u/Projects/fireflutter/live-projects/YOUR_PROJECT_FOLDER/",
"type": "dart",
"request": "launch",
"flutterMode": "debug",
"args": [
// "--web-port",
// "8080",
// "--no-sound-null-safety",
// pass your arguments here, whatever you would type
//in the terminal when you would use i.e
//flutter run --no-sound-null-safety[I love null safety by the way,
//but this is a common problem for people who still want to opt out of it.
],
}
],
"dart.flutterSdkPath": "/home/u/Downloads/sdks/flutter",
"dart.sdkPath": "/home/u/Downloads/sdks/flutter/bin/dart",
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.