为了解决该错误,您需要以
Main如下所示的home参数调用类
MaterialApp。
void main() => runApp(MyApp());class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( title: 'Welcome to Flutter', debugShowCheckedModeBanner: false, home: Main(), ); }}Main并将您的Class中的Build方法更新为:
@override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text('Welcome to Flutter'), ), body: Column(children: <Widget>[ Center( child: Text('Hello World'), ), RaisedButton( onPressed: () { print("pushed?"); _showPushDialog(context); }, child: Text("press me"), ) ]), ); }


