1 代碼不聯想
VSD配置Dart都成功以後,直接新建一個 .dart 文件,結果代碼不聯想,瞬間感覺不好了
有一個警告:For full Dart language support, please open a folder containing your Dart files instead of individual loose files
好吧,原來是直接新建一個 .dart 文件進行編輯不支持,需要新建一個文件夾,再在裏面新建 .dart文件就可以了
就是打開隨便哪個盤,新建一個文件夾,用VSD打開,再新建 .dart文件就可以了
2 assert不執行 及調試模式啥意思
assert說在調試模式下才會執行,調試模式啥意思呢,就是你debug就是調試模式
VisualStudioCode怎麼debug呢: 運行 —> 調試
然後報錯: Your launch config references a program that does not exist. If you have problems launching, check the "program" field in your ".vscode/launch.json" file.
就是說在 .vscode下面有一個 launch.json 的文件,文件裏面program對應的東西找不到
然後就OK 了。
debug模式下,assert就會執行,如果返回false會直接報錯
3 with 報錯
錯誤:The class 'B' can't be used as a mixin because it declares a constructor.dart(mixin_class_declares_constructor)
class A{
A(){
}
}
class B with A{
// 此時會報錯:
// The class 'B' can't be used as a mixin because it declares a
// constructor.dart(mixin_class_declares_constructor)
// 就是 說A無法作爲一個mixin 因爲他有構造函數
// 把類A 裏面的構造函數刪除 就可以了
}