声明 Widget 和 new Widget 的区别是什么?
例子:
例子:
appBar: AppBar(... ),
appBar: new AppBar(... ),
title: Text('Hi'),
title: new Text('Hi'),
new
和在常量上下文中使用的const
已经变成了可选项。因此,在以下情况下,Dart会自动假定new
或const
(根据上下文),如果以下标识符是一个具有默认构造函数的类(或者如果您使用MyWidget.fooName()
,则为命名构造函数):查看 https://github.com/dart-lang/sdk/blob/master/docs/language/informal/optional-new-const.md。请注意保留HTML标记。