import 'package:flutter/material.dart';
// void main() {
// runApp(
// MaterialApp(
// debugShowCheckedModeBanner: false,
// home: Scaffold(
// appBar: AppBar(
// title: Text("第一个Flutter程序")
// ),
// body: Center(
// child: Text(
// "Hello World",
// style: TextStyle(
// fontSize: 40,
// color: Colors.blue,
// ),
// ),
// )
// )
// )
// );
// }
///简化写法 void main() => runApp(const MyApp());
void main() {
runApp(const MyApp());
}
/// App根Widget
class MyApp extends StatelessWidget{
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return const MaterialApp(
debugShowCheckedModeBanner: false,
home: HomePage(),
);
}
}
/// 页面Widget
class HomePage extends StatelessWidget{
const HomePage({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
centerTitle: true,
backgroundColor: Colors.grey,
title: Text(
"第一个Flutter程序"
),
),
body: const Center(
child: Text(
"Hello World",
style: TextStyle(
fontSize: 38,
color: Colors.blue,
),
),
),
);
}
}