第一个Flutter页面里的main函数
笔者左右无法肉眼识别哪些是系统生成的,哪些是需要开发者手写的,只有在最初的阶段通过加强多写页面来形成肌肉记忆了。下述是main函数的
import 'package:exercise_home_page/app_center.dart';
import 'package:flutter/material.dart';
import 'home_page.dart';
import 'message_center.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: MessageCenter(),
);
}
}
import 'package:flutter/material.dart';
class MessageCenter extends StatefulWidget
{
const MessageCenter({super.key});
@override
State createState() {
return _State();
}
}
class _State extends State
{
@override
Widget build(BuildContext context) {
return Container(
color: Colors.orange,
);
}
}