Class 以下方法如何可能使用;“语法糖”;预留给建设者?
为了说明我的观点,以下代码包含一个名为ColorValueChanger的方法,该方法使用this.passedIn作为可选参数。我以为这是给施工人员的Class 以下方法如何可能使用;“语法糖”;预留给建设者?,class,flutter,oop,dart,constructor,Class,Flutter,Oop,Dart,Constructor,为了说明我的观点,以下代码包含一个名为ColorValueChanger的方法,该方法使用this.passedIn作为可选参数。我以为这是给施工人员的 class Foo extends StatefulWidget { final String passedIn; // Value passed in from its host ColorValueChanger({Key key, this.passedIn}) : super(key: key); _FooState creat
class Foo extends StatefulWidget {
final String passedIn;
// Value passed in from its host
ColorValueChanger({Key key, this.passedIn}) : super(key: key);
_FooState createState() => new _FooState();
}
class _FooState extends State<Foo> {
@override
Widget build(BuildContext context) {
return Text(widget.passedIn,);
}
}
class Foo扩展StatefulWidget{
最后一个字符串passedIn;
//从其主机传入的值
ColorValueChanger({Key-Key,this.passedIn}):超级(Key:Key);
_FooState createState()=>新建;
}
类_FooState扩展了状态{
@凌驾
小部件构建(构建上下文){
返回文本(widget.passedIn,);
}
}
它是一个构造函数。
这听起来更像是示例中的输入错误
固定代码为:
class Foo扩展StatefulWidget{
最后一个字符串passedIn;
//从其主机传入的值
Foo({Key-Key,this.passedIn}):super(Key:Key);
_FooState createState()=>新建;
}
类_FooState扩展了状态{
@凌驾
小部件构建(构建上下文){
返回文本(widget.passedIn,);
}
}
它是一个构造函数。
这听起来更像是示例中的输入错误
固定代码为:
class Foo扩展StatefulWidget{
最后一个字符串passedIn;
//从其主机传入的值
Foo({Key-Key,this.passedIn}):super(Key:Key);
_FooState createState()=>新建;
}
类_FooState扩展了状态{
@凌驾
小部件构建(构建上下文){
返回文本(widget.passedIn,);
}
}