You seem to be missing the main function which is the entry point and runApp function responsible for launching the app:
main() is the entry point of the app. main() is responsible for launching the app by calling runApp().
The runApp() function takes a widget (usually MaterialApp) and inflates it to display the initial UI on the screen.
Also i noticed you are calling the same class in MaterialApp>home which is not possible to do. Below is your code modified and corrected:
import 'package:flutter/material.dart';
void main() {
runApp(const HomeScreen());
}
class HomeScreen extends StatefulWidget {
const HomeScreen({super.key});
@override
State<HomeScreen> createState() => _HomeScreenState();
}
class _HomeScreenState extends State<HomeScreen> {
@override
Widget build(BuildContext context) {
return const MaterialApp(
debugShowCheckedModeBanner: false,
//home: HomeScreen(), //REQUIRE TO CHANGE THIS TO ANOTHER CLASS
home: const NewScreen(),
);
}
}
Here is the link to better understand main function and different variations.