0

我正在使用 WebStorm 和 Dart Angular,但在使用某种严格或检查模式时遇到了问题。

每当我使用默认 WebStorm 配置运行应用程序时,我都会收到 failed assertionsObserver reaction functions should not change model.和.boolean expression must not be nulltype 'SubListIterable' is not a subtype of type 'List<Tag>'

据我了解,这是因为 Dart VM 正在检查模式下运行,我想将其关闭。Dartium 是通过 options 启动的--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;
}

我必须invalidateCorrectTagstrue每个 setter 中设置,其中所述 setter 的更改将影响 getCorrectTags 的结果。有没有更好的方法呢?

4

1 回答 1

2

最近从 WebStorm 中删除了禁用检查模式的选项

https://youtrack.jetbrains.com/issue/WEB-24466

提到的解决方法是添加

<entry key="DART_FLAGS" value="--checked" />

[configuration]/options/web-browsers.xml

于 2017-02-13T09:43:10.440 回答