Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Class 以下方法如何可能使用;“语法糖”;预留给建设者?_Class_Flutter_Oop_Dart_Constructor - Fatal编程技术网

Class 以下方法如何可能使用;“语法糖”;预留给建设者?

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

为了说明我的观点,以下代码包含一个名为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 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,);
}
}