mainexplain
Import Flutter packages:
This line imports the necessary Flutter packages, including
material.dart
, which provides widgets for building material design applications.Define the main function and runApp:
The
main
function is the entry point of the application. It callsrunApp
to start the Flutter application and render theMyApp
widget.MyApp
Class:This class represents the top-level widget of your application. It is a stateless widget, so it doesn't have mutable state. It defines the overall structure of the app.
title
: The title of the app is set to "Flutter Demo."theme
: The theme is set to use the primary color swatch of blue.home
: TheMyHomePage
widget is set as the home screen of the app with the title "Flutter Demo Home Page."
MyHomePage
Class:This class represents the main content of the app, which is a simple page with an app bar and a "Hello World" message in the center. It also inherits from
StatelessWidget
.title
: The title for the app bar is passed as a parameter and displayed in the app bar.The
build
method creates aScaffold
widget, which provides the basic material design structure for the screen.The
appBar
property sets anAppBar
with the title set to the providedtitle
.The
body
property sets the main content to be a centeredText
widget with the text "Hello World."UML
Widget Tree
Last updated