3

I'm really new to programming with Dart and I'm currently following a Flutter tutorial to make a Unit Convert(Official Google tutorial). I've been looking for some help lately and I saw that in every code in Dart for flutter it was written 'new' before some widgets. I was just wondering why because new never appears in the tutorial that I'm following.

Thanks!

JayP
  • 43
  • 1
  • 4

2 Answers2

2

New is no longer necessary in Dart 2.0.

It's superfluous - it will show up in old tutorials but you don't need to use it, and you should not.

Because Dart 2 is so new and so many tutorials available were written for Dart 1 it might be useful to read the changes between Dart 1 and 2: https://www.dartlang.org/dart-2

powerj1984
  • 2,216
  • 1
  • 22
  • 34
0

new became optional a few weeks ago. new is used to call the constructors of a class to create a new object instance.

const is similar for const constructors but only optional in a const context.

Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567