0

I am trying to find out what the status of avoiding unchecked access to null with compiler/analyzer support is in Dart.

Having done a couple of years of TypeScript, their strict default-non-null was a huge step forward in making code much safer. I like that even more than the Option-semantics of Scala.

Is there an analyzer option that is able to track down (all) potential null access through flow analysis?

For example, the following code should fail:

void foo(String b) {
  print(b.length);
}

void main() {
  foo(null);
}

It should report like: Unchecked null access in line 2 due to passing null in line 6.

So as a developer, I can then decide to fix line 1 or 2.

user3612643
  • 5,096
  • 7
  • 34
  • 55

1 Answers1

0

There is no such support at the current time.

The Dart language team is actively working on adding non-nullable types to the Dart type system. This will be a major change, so it won't be done in the first few quarters.

lrn
  • 64,680
  • 7
  • 105
  • 121