Dart Introduces Sound Null Safety

Null safety accommodates you to avoid a class of bugs that are often hard to spot. Now you get static errors as you code instead of pesky runtime null dereferencing errors.

Recently, Dart team announced the early tech preview of its null safety feature. The team said that Null safety helps you avoid a class of bugs that are often hard to spot. And as an added bonus it facilitates a range of performance improvements.
 
Dart team said that with null safety you now get static errors as you code instead of pesky runtime null dereferencing errors.
 
Well, Dart is a type-safe language, meaning that when you get a variable of some type, the compiler can guarantee that it is of that type. But type safety by itself doesn’t ensure that the variable is not null. Null errors are quite common.
 
The Dart team has defined three core design principles for null safety feature, Non-nullable by default, Incrementally adoptable, and Fully sound. If you do not explicitly tell that a variable can be null, Dart will consider it non-nullable.
 
The team said that Dart’s null safety is sound, meaning that Dart is 100% sure that the files list, and the elements in it, cannot be null. So, when Dart examines your code and concludes that a variable is non-nullable, that variable is always non-nullable. If a programmer inspects his running code in the debugger, he/she will see that non-nullability is retained at runtime.
 
 
Source: Dart
 
Since Dart is really sure that files is never null, Dart can optimize. The Dart ahead-of-time compiler can render smaller and faster native code, because it doesn’t need to add checks for nulls when it knows that a variable isn’t null. The team has observed around 20% performance improvement in a microbenchmark that emulates typical Flutter framework rendering patterns.
Also, Null safety is backwards compatible.
 
The feature soon will be available in Dart’s beta channel.
 
For additional detail, you can visit the official announcement here.