无法在flutter中使用Scaffold widget,出现以下错误:必须提供必需的参数“home”

问题描述 投票:0回答:1

我正在使用 android studio 2022 构建一个 flutter 应用程序,但是当我使用 Scaffold 时,它显示应该提供“home”,但 flutter 文档页面上没有文档显示 Scaffold 小部件具有该参数。以下错误:

required parameter 'home' must be provided,

还有一些类似上面的错误。

我正在使用 flutter 3.24 和 dart 3.5

flutter
1个回答
0
投票
Check the comment Under the material widget home is missing maybe in your code this error only occurred when you skipped the home parameter.



class MyApp extends StatelessWidget {
      @override
      Widget build(BuildContext context) {
        return MaterialApp( 
          home: MyHomePage(),  // Ensure you provide the 'home' parameter here
        );
      }
    }
© www.soinside.com 2019 - 2024. All rights reserved.