Strong type is now VERY STRONG

Dart 2 brings major changes to improve client-side development

Jane Elizabeth
dart 2
© Shutterstock / Pachai Leknettip

Dart 2 is here! There’s a lot to look at in the latest edition, including a brand new approach to the type system, improved client-side development

Dart 2 has arrived! It’s been a while, but we’ve been eagerly awaiting all the major changes this release has in store for us. Dart 2 is something of a major reboot for the language, bringing it closer in line to what its creators originally intended.

This updated version is meant to improve client-side development and show off the benefits of strong mode – now types are mandatory. Dart 2 also promises to make it easier for users to report issues and get those issues resolved.

Strong mode in Dart 2

Big changes are afoot in Dart 2. The major one is types. In Dart 1, types were optional. Now, they are mandatory. (Type annotations are still optional.) This isn’t exactly news, though; last year, the Dart team announced the language would make the switch to a sound static type system as part of the development to the next release.

Strong mode would become the default type system. This was mean to help developers find more bugs at compile time and not at runtime. Plus, refactoring tools and code completion worked better with strong mode.

So, what’s the big difference between how these types were used between Dart and Dart 2? In Dart, the analyzer infers the dynamic type. In Dart 2, tools like the analyzer can often infer types that are more specific than dynamic, following rules in the language specification.

While Dart 2 is statically typed, type inference and less precise types such as dynamic and num take away much of the burden of specifying exact types. Dart 2 has the advantages of a strongly typed language, but requires only a bit more work than Dart 1.

Head on over to the documentation for more information about Strong mode.

SEE MORE: Flutter: A beautiful mix of React and Dart for mobile SDK

Client-side development

Dart 2 brings a lot of client-side improvements, including UI as a code. Developers no longer need to switch as much between a separate UI markup language and the programming language used to write the app. By making the definition of UI as code, Dart 2 dramatically reduces the need for context switching.

Dart 2 is also introducing the optional new and const. This makes it possible for developers to clean up the definition of a UI widget so that it doesn’t use a single keyword.

// Before Dart 2
Widget build(BuildContext context) {
  return new Container(
    height: 56.0,
    padding: const EdgeInsets.symmetric(horizontal: 8.0),
    decoration: new BoxDecoration(color:[500]),
    child: new Row(

// After Dart 2
Widget build(BuildContext context) =>
    height: 56.0,
    padding: EdgeInsets.symmetric(horizontal: 8.0),
    decoration: BoxDecoration(color:[500]),
    child: Row(

SEE MORE: Creating apps with Dart and Stagehand

Dart 2 also makes it easier for client-side users as well. On the mobile side, Flutter is a mobile UI framework that allows users to create high-quality interfaces for iOS and Android. Do you love Hamilton on the mobile app? That was built with Flutter.

And on the web side, Dart’s web-specific libraries and full Dart-based web framework make things easier for teams for web development.

Getting Dart 2

First off, Dart 2 is still landing. That means various changes are still in motion, so you should check the changelog for full details. If you’re interested in migrating over from Flutter, they have a specific wiki available for you.

Dart 2 is available here or on GitHub. This language is open source and contributors to the core SDK are welcome.

Jane Elizabeth
Jane Elizabeth is an assistant editor for

Inline Feedbacks
View all comments