Build: Hello World Screen
This screen shows a simple greeting message in the center.
Target UI
--------------------- | | | | | Hello World | | | | | ---------------------
--------------------- | | | | | Hello World | | | | | ---------------------
import 'package:flutter/material.dart'; void main() { runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({super.key}); @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Demo', home: Scaffold( appBar: AppBar( title: const Text('Welcome'), ), body: Center( // TODO: Add your code here ), ), ); } }
import 'package:flutter/material.dart'; void main() { runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({super.key}); @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Demo', home: Scaffold( appBar: AppBar( title: const Text('Welcome'), ), body: const Center( child: Text( 'Hello World', style: TextStyle(fontSize: 24), ), ), ), ); } }
We use a MaterialApp as the root widget to provide material design styling. Inside it, a Scaffold gives us a basic page layout with an AppBar titled 'Welcome'. The main content is centered using Center, and inside it, a Text widget displays 'Hello World' with a font size of 24 to make it easy to read.
--------------------- | Welcome | |-------------------| | | | Hello World | | | ---------------------
void main() {
runApp(MaterialApp(
home: Scaffold(
body: Center(
child: Text('Hello Flutter'),
),
),
));
}void main() {
runApp(MaterialApp(
home: Scaffold(
body: Center(
child: Text('Hello World')
),
),
));
}Pass the test and this pattern moves unknown