第一个Flutter页面里的main函数

avatar
作者
筋斗云
阅读量:0

笔者左右无法肉眼识别哪些是系统生成的,哪些是需要开发者手写的,只有在最初的阶段通过加强多写页面来形成肌肉记忆了。下述是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<StatefulWidget> createState() {
return _State();
}

}

class _State extends State<MessageCenter>
{
@override
Widget build(BuildContext context) {
return Container(
color: Colors.orange,
);
}

}

广告一刻

为您即时展示最新活动产品广告消息,让您随时掌握产品活动新动态!