Flutter with Dart 2

Dart 2 is in pre-release, and you can now test your flutter apps against it. It's pretty simple.

Simply add the --preview-dart-2 flag as follows:

flutter run --preview-dart-2

(The --strong argument can also be quite useful)

Also, make sure to run a flutter upgrade to make sure you are on the latest version. This flag is not effective until flutter 0.0.21 which went to Alpha on 2018-01-29.

Now you can use some nifty Dart 2 things, like leaving out new and const!

class OctalClockApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Octal Clock',
      theme: ThemeData(
        primarySwatch: Colors.blue,
        fontFamily: 'Fixed',
      ),
      debugShowCheckedModeBanner: false,
      home: ClockPage(),
    );
  }
}

For more information see https://github.com/flutter/flutter/wiki/Trying-the-preview-of-Dart-2-in-Flutter

Brian Armstrong

A web application developer with 15+ years programming experience. Flutter evangelist, React.js enthusiast.

Read More