控件和新控件之间的区别

Ada*_*n P 2 widget dart flutter

声明小部件新小部件有什么区别

例:

appBar: AppBar(... ),
appBar: new AppBar(... ),

title: Text('Hi'),
title: new Text('Hi'),
Run Code Online (Sandbox Code Playgroud)

Gün*_*uer 5

new并且在const上下文中,const最近已变为可选。

因此,没有区别,如果以下标识符是具有默认构造函数的类(如果使用,则为命名构造函数),Dart只是假设newconst(取决于上下文MyWidget.fooName()

另请参见https://github.com/dart-lang/sdk/blob/master/docs/language/informal/optional-new-const.md