【发布时间】:2020-08-13 22:02:06
【问题描述】:
为了说明我的观点,以下代码包含一个名为 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 flutter oop dart constructor