VS代码中呈现的基本Flutter小部件中的错误

时间:2019-03-15 10:56:56

标签: visual-studio-code flutter

我是陌生的,创建了一个演示应用程序。只是使用无状态小部件


void main() => runApp(new MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      debugShowCheckedModeBanner: false,
      home: Scaffold(
          appBar: AppBar(
            title: Text("Hello my app"),
          ),
          body: HelloRectangle()),
    );
  }
}

class HelloRectangle extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Container(
      color: Colors.blueAccent,
    );
  }
}

但是它显示了错误:

Error -32601 received from application: Method not found
Reloaded 0 of 432 libraries in 525ms.

是否总是需要将类命名为MyApp,因为如果更改了名称我将无法运行它。我正在使用VS CODE运行flutter,并运行“启动调试选项”

0 个答案:

没有答案