BT

Dart 2 Revamped for Mobile Development

| by Sergio De Simone Follow 14 Followers on Feb 24, 2018. Estimated reading time: 1 minute |

The latest version of Google’s Dart programming language, sporting a strengthened type system, cleaned-up syntax, and an improved toolchain, is being touted by Google as the way to go for Mobile and Web app development, enabling a 2–3x productivity increase.

Dart 2 makes its strongly-typed mode mandatory to ensure bugs are caught earlier in the development process. Type annotations remains optional, though, and types are inferred when not declared. You can preview the readiness of your Dart 1.x code for Dart 2 by enabling Dart 1.x strong mode.

A relatively minor change to the language that has a big impact on Dart syntax readability is the ability to omit new and const when calling a constructor. This makes it possible to declare UI using a more declarative syntax. For example you can now write:

Widget build(BuildContext context) =>
  Container(
    height: 56.0,
    padding: EdgeInsets.symmetric(horizontal: 8.0),
    decoration: BoxDecoration(color: Colors.blue[500]),
    child: Row(
      ...
    ),
  );

instead of the following Dart 1.x-compatible version:

Widget build(BuildContext context) {
  return new Container(
    height: 56.0,
    padding: const EdgeInsets.symmetric(horizontal: 8.0),
    decoration: new BoxDecoration(color: Colors.blue[500]),
    child: new Row(
      ...
    ),
  );
}

Dart supports mobile app development through Google’s Flutter framework, which aims to make it possible to create native UIs for Android and iOS. Flutter is able to natively compile to ARM and x86 processors. When coupled with Flutter’s engine, which provides an efficient garbage collector, this makes it possible to create mobile apps that run entirely natively.

The shift in Dart’s positioning for client-side development is confirmed by Google product manager for Dart Anders Thorhauge Sandholm:

The focus for us in evolving the Dart language and libraries is on maximizing the value and utility for client-side development.

This does not mean, though, that Dart usage for command-line or server-side code is being deprecated. Dart’s new focus on client-side development may be seen as an attempt by Google to increase Dart’s adoption across the industry outside of Google, which remains its biggest adopter. According to Sandholm, the performance and predictability of Dart, along with its sound type system, allowed Google AdWords engineers to be two- to three-times more productive than before. Additionally, Sandholm says, Google teams using Dart on AdWords Express and AppTree have been able to share between 50% and 70% of code across mobile and web.

Rate this Article

Adoption Stage
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread
Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Discuss

Login to InfoQ to interact with what matters most to you.


Recover your password...

Follow

Follow your favorite topics and editors

Quick overview of most important highlights in the industry and on the site.

Like

More signal, less noise

Build your own feed by choosing topics you want to read about and editors you want to hear from.

Notifications

Stay up-to-date

Set up your notifications and don't miss out on content that matters to you

BT