由于新的flutter版本中添加了空安全的限制,所以在使用VSC运行Flutter项目时,只能使用命令行
flutter run --no-sound-null-safety,并且每次更新都需要手动进行热重启,十分麻烦。
解决方案:
在项目根目录下的.vscode文件夹下创建文件launch.json,并做如下配置
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "hollebug",
"request": "launch",
"type": "dart",
"args": [
"--no-sound-null-safety"
]
},
{
"name": "hollebug (profile mode)",
"request": "launch",
"type": "dart",
"flutterMode": "profile"
},
]
}
亲测,又可以实现自动热重载了