在创建简单的StatefulWidget时,出现type 'MyApp' is not a subtype of type 'StatelessWidget'
错误。
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatefulWidget{
@override
State<StatefulWidget> createState() {
// TODO: implement createState
return _MyAppState();
}
}
class _MyAppState extends State<MyApp>{
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(appBar: AppBar(title: Text("My App"),),),
);
}
}
该错误的可怕之处在于它显示:
要么断言表明框架本身存在错误,要么我们应该在此错误消息中提供更多的信息,以帮助您确定和解决根本原因。
是框架问题还是我的实现问题?