我自己写的,因为 statefulwidget 没有自动创建模式,并且在 7 个不同的错误中我无法解决这个问题
class NaberMain extends StatefulWidget {
NaberMain({Key key}) : super(key: key)
// ignore: empty_constructor_bodies
@override
_NaberMainState createState() => _NaberMainState();
}
class _NaberMainState extends State<NaberMain> {
@override
Widget build(BuildContext context) {
return Container(
);
}
}```
Run Code Online (Sandbox Code Playgroud)
之后缺少一个分号super(key: key)。添加分号。
class NaberMain extends StatefulWidget {
NaberMain({Key key}) : super(key: key); //This is the semi-colon.
@override
_NaberMainState createState() => _NaberMainState();
}
class _NaberMainState extends State<NaberMain> {
@override
Widget build(BuildContext context) {
return Container(
);
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1996 次 |
| 最近记录: |