第一次提交

This commit is contained in:
2026-03-09 23:56:08 +08:00
parent 9395dfd38b
commit aad3c251a5
131 changed files with 4853 additions and 1 deletions

6
lib/main.dart Normal file
View File

@@ -0,0 +1,6 @@
import 'package:flutter/material.dart';
import 'package:mydearest/routes/index.dart';
void main(List<String> args) {
runApp(getRootWidget());
}

View File

@@ -0,0 +1,23 @@
// 不清楚需求一律使用有状态组件
import 'package:flutter/material.dart';
class LoginPage extends StatefulWidget {
const LoginPage({super.key});
@override
State<LoginPage> createState() => _LoginPageState();
}
class _LoginPageState extends State<LoginPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Login"),
),
body: Center(
child: Text("This is the login page."),
),
);
}
}

22
lib/pages/main/index.dart Normal file
View File

@@ -0,0 +1,22 @@
import "package:flutter/material.dart";
class MainPage extends StatefulWidget {
const MainPage({super.key});
@override
State<MainPage> createState() => _MainPageState();
}
class _MainPageState extends State<MainPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Main Page"),
),
body: Center(
child: Text("This is the main page."),
),
);
}
}

21
lib/routes/index.dart Normal file
View File

@@ -0,0 +1,21 @@
// 管理路由
import 'package:flutter/material.dart';
import 'package:mydearest/pages/main/index.dart';
import 'package:mydearest/pages/login/index.dart';
// 返回APP根组件
Widget getRootWidget() {
return MaterialApp(
routes: getRootRoutes(),
);
// 真正的项目都是使用的命名路由
}
// 返回路由表
Map<String, Widget Function(BuildContext)> getRootRoutes() {
return {
"/": (context) => MainPage(), // 主页路由
"/login": (context) => LoginPage(), // 登录页路由
};
}