FLUTTERING DART

Fluttering Dart: Null Safety

Dart’s upcoming superpower

Constantin Stan
4 min readJul 7, 2020

--

A splash of coffee.
Photo by Ohmky on Unsplash

What is it?

Null safety is the guarantee within an object-oriented programming language that the object references will never have null values.

That translates into 0 "chances" of getting a null reference error. So no more unexpected application crashes caused by this "billion-dollar mistake", as Tony Hoare called the invention of the null pointer.

Currently, JetBrain’s Kotlin and Apple’s Swift are the ones of the most popular programming languages that use null-safe types by default. Soon, Google’s Dart will join the select club.

How will it work?

The types in our code will be considered non-nullable by default. This means that values can’t be null unless specifically marked by us as nullable.

With this, our runtime null-dereference errors turn into edit-time analysis errors and the Dart analyzer can enforce some good practices. For example, it can make sure we check for null before reading a nullable variable.

Also, the Dart compilers and runtimes can optimize away internal null checks, so apps can be faster and smaller.

When will it happen?

--

--