import 'package:flutter/material.dart'; void main() { runApp(MyApp()); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( home: MyHomePage(), ); } } class MyHomePage extends StatefulWidget { @override _MyHomePageState createState() => _MyHomePageState(); } class _MyHomePageState extends State<MyHomePage> { @override Widget build(BuildContext context) { return Scaffold( body: Center( child: Text('Hello,World!'), ), ); } }
MaterialApp Widget allows us to use the material widgets within the application where as scaffold provides additional functionalities such as adding an app bar within the app, adding a floating action button and so on. Scaffold gives us screen space to work on.
Within the Scaffold widget we have a body property. We have passed a Center Widget in the body to make our text centered and we in turn have used the text widget to get the application render text.
So our basic tree is structured as follows.
We will be using MaterialApp and Scaffold almost every time.
->MaterialApp
-> Scaffold
->Center
-> Text
The Output of this application is
If you enjoy this post, keep coming. We have got a ton of content for you. Join our mailing list and subscribe to this blog.