Question

This small program generate this warning in Dart Editor.

This is just sample but not the real code. But real code are similar (and bigger).

void main() {
  var what_I_if_not_want_compile_to_js;
  var so_what = what_I_if_not_want_compile_to_js is double;
}

Warning: "When compiled to JS, this test might return true when the left hand side is an int"

P.S.

No problem. But I have 22 lines of this warnings (in "Problems" view) in one of my programs.

Can I disable them somehow?

I cannot avoid this test. Here is code from real program.

dynamic _cast(value) {
  if(value is double) {
    value = value.toInt();
  }

  if(value is int) {
    if(value >= -2147483648 && value <= 2147483647) {
      return value;
    }

    value &= 0xffffffff;
    return value <= 2147483647 ? value : value - 0x100000000;
  } else if(value is CData && value.type is ReferenceType) {
    return _cast(value._address);
  } else {
    return super._cast(value);
  }
}
Was it helpful?

Solution

You can turn off dart2js related hints in Dart Editor by going to Tools-> Preferences -> Hints and unchecking the "Enable dart2js related hints" checkbox.

There are also plans to allow for manually suppressing certain warnings. You can follow the issue.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top