import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: GreetingScreen(),
);
}
}
class GreetingScreen extends StatelessWidget {
const GreetingScreen({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Greeting'),
),
body: const Center(
child: Text('Hello, Flutter!'),
),
);
}
}We created a GreetingScreen class that extends StatelessWidget. This means the UI does not change after it is built. Inside the build method, we return a Scaffold which provides the basic visual layout structure. The AppBar shows the title 'Greeting'. The body uses a Center widget to place the Text widget in the middle of the screen. The text says 'Hello, Flutter!'. This is a simple static screen perfect for learning how to use StatelessWidget.