A semi-accurate depiction of the universe of void-like types in Dart2

One of the questions I see the most asked on StackOverflow, Gitter, and even Google-internal support channels is the difference between the following built-in types in Dart 2: , , , and .

Long-story short, (or in other languages, i.e. “Nothing”) shouldn’t be used in most real user-code, and I suspect we’ll see more articles and lints in the near future to gently discourage usage.

The rest of the three are not as clear, because something in Dart 2 anything can be , or at runtime, varying only by the static type signature. …


One of the most exciting changes to Dart, in Dart 2, is the holy grail combination of removing optional types and adding powerful type inference.

The former means there is no more differentiation between a “checked” (type annotations kind of matter) and “unchecked” mode (type annotations don’t matter at all). The latter means, for already well-typed applications, you won’t have to do much!

Dart 1

Let’s review how type annotations worked in Dart 1.0, first:

void main() {
String name = 5;
print(name + 2); // 7
}

This is valid, both syntactically and semantically, in Dart 1. Dart 1 also shipped…


I participated in Ludum Dare 40 with a group of friends who are mostly non-programmers. The end result of our terrible game is here (source code). I thought about several different languages to build with, but settled on a browser-based game for ease of use (nobody needs a special device). I wanted to try something other than Dart — of which I currently work on at Google.

TypeScript in itself is just a language and a compiler/type-checker combination, and doesn’t provide much other opinions . So I used this stack:


Data binding as popularized by the Angular (MVC-style). Lots of arrows and pictures. That’s always a good sign.

Data binding, or updating the view (usually UI) from your application’s code is probably the holy grail of browser-based web frameworks — the reason they exist, and the reason web standards have tried to shift in order to make it easier to “use the platform”.

In this blog post I’ll be reviewing four forms of data binding, and writing a simple library/throw-away framework for each — mostly as a learning experience. …


As an example of how to build FRP (functional-reactive program[s]) in Dart, I decided to try building an FPS counter — that is, an utility to determine what the frame rate of a running application is.

The end result after building package:fps.

I decided I’d like to have a few goals:

  1. The library, hereby package:fps, should be platform agnostic. That is, I didn’t want to require the use of the browser (requestAnimationFrame) — it should work also in the standalone command-line VM and Flutter.
  2. I wanted it to be extensible — it should be relatively trivial to get the average FPS over a duration of time…


One of the most common questions I get for Dart, even within Google, is “how do I make my code more reusable?”. We work on large projects like AdWords, AdSense, and Google’s internal CRM, Greentea — which are all written in Dart.

Reusable bags are sort of like reusable code, right?

I was working with an engineer who was iterating on a new API for the AngularDart router, where we are modeling route changes as immutable state changes:

You can try this demo on DartPad.

A question was asked while developing this, though:

A [large] customer says that the default behavior of stripping the query parameters as you navigate…


We’re constantly talking on the Dart team about how to improve the language (like non-nullable types), and one of the features that has come up informally a few times is function overloading:

In some programming languages, function overloading or method overloading is the ability to create multiple methods of the same name with different implementations. Calls to an overloaded function will run a specific implementation of that function appropriate to the context of the call, allowing one function call to perform different tasks depending on context.

In short, this means you can write code like this (here’s a Java example):


Well, no. Dart has a single thread, or event-loop, of execution. However, commonly you’ll see a code using Future have a comment something to the effect of “// Avoid race conditions: Check for …”. What does that mean?

New to futures? Read asynchronous programming: Futures on the Dart site.

While Dart has a single thread of execution, it can interact with other code (Dart or otherwise, such as server-side) that runs in a separate thread. What Future<T> as an API means is simply “get a value, T, at a future point in time”. That time? It could be at the…


It’s impossible to deny that immutability is a hot topic in programming, especially front-end programming. Libraries like Immutable.js and other concepts like unidirectional data flow have argued it’s easier to reason about data when it doesn’t change underneath you:

In object-oriented and functional programming, an immutable object (unchangeable object) is an object whose state cannot be modified after it is created. This is in contrast to a mutable object (changeable object), which can be modified after it is created.

Well, what about Dart? We have a couple concepts that lend themselves well to immutability and immutable objects built-in, starting with…


A little known fact: Angular Dart has supported lazy loading since 1.0.

What does lazy loading (called deferred loading in Dart) do for you?

  • You can break up your application into small, dependent parts
  • It works on every browser — automatically without polyfills
  • Use fully typed Dart code — even your deferred libraries are typed

Don’t worry — you don’t need any extra plugins, loaders, build steps, or dependencies of any kind. It’s completely built in (albeit, I admit relatively undocumented — we’re working on that).

This tutorial expects you to already be familiar with Dart and Angular Dart.

Getting started

I…

Matan Lurey

Software engineer @Google and @Dart_Lang. Opinionated.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store