为什么Flutter MaterialApp Widget会显示错误“所需参数不足”

时间:2018-11-25 11:05:57

标签: android dart flutter

对于第一个flutter sdk可用的flutter项目,MaterialApp flutter小部件给出错误“期望1个必需参数,但找到0个”。我在VScode上运行它。这是代码。预先感谢。

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(   // This line is giving Error at'('
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

1 个答案:

答案 0 :(得分:0)

我使用VSCode遇到了完全相同的问题,发现此问题可以解决此问题:

在Flutter安装目录中运行以下命令:

  • git clean -xfd
  • git stash save --keep-index
  • git藏匿点
  • git pull
  • 颤抖的医生

https://github.com/flutter/flutter/wiki/Workarounds-for-common-issues#flutter-installation-corrupted