I’m using android studio 2022 to build a flutter app, but when I using Scaffold it show that ‘home’ should be provided but there is no doc on flutter document page show that Scaffold widget has that parameter. The following errors:
required parameter 'home' must be provided,
and some similar errors like above.
class MyFirstApp extends StatelessWidget {
const MyFirstApp({super.key});
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: HomeScreen(),
);
}
}
class HomeScreen extends StatefulWidget {
const HomeScreen({super.key});
@override
State<StatefulWidget> createState() => HomeState();
}
class HomeState extends State<HomeScreen> {
@override
Widget build(BuildContext context) {
return Scaffold( //the error shown here: required parameter 'home' must be provided
body: const Text("Hello world")
)
}
}
I’m using flutter 3.24 and dart 3.5
2
Answers
The problem is caused by dart-tool folder with generated files. I used the
flutter_localization
package on my project but when I clone it from github in another devices and it didn't have dart-tool with generated files so dart-tool didn't work properly. I just setup and configure again and it solved! Thanks.Check the comment. Under the material widget, home is missing. Maybe, in your code, this error only occurred when you skipped the home parameter.