[英]Disable strict/checked mode in Dart Angular
我正在使用WebStorm和Dart Angular,但在某種嚴格或檢查模式下遇到問題。
每當我使用默認的WebStorm配置運行該應用程序時,我都會收到失敗的斷言Observer reaction functions should not change model.
, boolean expression must not be null
且type 'SubListIterable' is not a subtype of type 'List<Tag>'
。
據我了解,這是因為Dart VM正在檢查模式下運行,我想將其關閉。 如果Dartium很重要,它會使用--no-sandbox --flag-switches-begin --flag-switches-end
選項啟動。
當我在Chrome中打開頁面時,一切都很好,但是我當然無法調試。
編輯:第一個錯誤顯然與檢查模式無關。 這是我嘗試實現的代碼片段:
List get getCorrectTags {
if(this.allowTags)
return this.tags.map((t) => t.name).toList();
else
return this.contentTags;
}
當前的解決方案是這樣的:
bool invalidateCorrectTags = false;
List correctTags = [];
List get getCorrectTags {
if (this.invalidateCorrectTags) {
this.invalidateCorrectTags = false;
if(this.allowTags)
this.correctTags = this.tags.map((t) => t.name).toList();
else
this.correctTags = this.contentTags;
}
return this.correctTags;
}
並且我必須在每個設置器中將invalidateCorrectTags
設置為true
,其中所述設置器中的更改將影響getCorrectTags的結果。 有更好的方法嗎?
最近從WebStorm中刪除了禁用檢查模式的選項
https://youtrack.jetbrains.com/issue/WEB-24466
提到的解決方法是添加
<entry key="DART_FLAGS" value="--checked" />
到[configuration]/options/web-browsers.xml
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.