1
Padding(
  child: Icon(Icons.search)
);

new Padding(
  child: new Icon(Icons.search)
);

The above two pieces of code achieve the same effect, when do us need to add "new"?

  • you can check this https://stackoverflow.com/questions/50091389/do-you-need-to-use-the-new-keyword-in-dart – Boby Mar 20 '19 at 03:47

2 Answers2

4

Since Dart 2.0 , new keyword is optional.

Rubens Melo
  • 3,111
  • 15
  • 23
0

Flutter need 'new' keyword in the lower version when create a object. In the newest version, 'new' keyword can be ignored

Jimmy Chen
  • 177
  • 5