Sir*_*dib 12 syntax constructor dart
class TapboxA extends StatefulWidget {
TapboxA({Key key}) : super(key: key);
}
Run Code Online (Sandbox Code Playgroud)
这部分 :
TapboxA({Key key})
Run Code Online (Sandbox Code Playgroud)
下半场
super(key: key);
Run Code Online (Sandbox Code Playgroud)
我理解,(对超类构造函数的调用).
但是什么是
{Key key}
Run Code Online (Sandbox Code Playgroud)
语法呢?
在Dart构造函数(和其他方法)中可以具有可选的命名参数:
MyClass({String namedParam}){//...}
Run Code Online (Sandbox Code Playgroud)
对于Flutter小部件构造函数:
TapboxA({Key key}) // TapboxA constructor defines a named parameters `key`
: super(key: key); //which is used within the super constructor call (which also has `key` as named parameter )
Run Code Online (Sandbox Code Playgroud)
您可以在Dart语言浏览中找到有关可选命名参数的更多信息。
| 归档时间: |
|
| 查看次数: |
3645 次 |
| 最近记录: |