基于 Flutter × HarmonyOS 6.0 的宿舍管理系统设计
背景
随着高校信息化建设的加速,新生入学流程逐步从人工登记转向智能管理。宿舍分配、入住登记、通知公告、报修反馈等场景高度碎片化,传统 Web 管理后台难以满足高并发与移动端实时交互的需求。
传统宿舍管理存在的问题
| 问题 | 说明 |
|---|---|
| 信息割裂 | 教务系统、后勤系统、人工登记不互通 |
| 流程混乱 | 新生不清楚入住步骤 |
| 数据不可视 | 管理员难以统计入住状态 |
| 通知滞后 | 重要公告无法触达学生 |
| 跨平台困难 | 安卓 / 鸿蒙 / iOS 多套代码 |
Flutter × HarmonyOS 6.0 跨端开发介绍
技术选型
| 技术 | 作用 |
|---|---|
| Flutter | 一套 Dart 代码,编译到 Android / iOS / Web |
| HarmonyOS 6.0 | 国产分布式系统,支持 ArkUI / Flutter |
| Flutter on Harmony | 使用 OpenHarmony Flutter 引擎,直接运行 |
架构示意
Flutter UI 层 → 业务逻辑层(ViewModel / Provider / Riverpod) → 数据层(Repository + API + 本地缓存) → HarmonyOS 分布式能力(设备互联 / 推送 / 存储)
数据结构设计
class Student {
String id;
String name;
String college;
String dormId;
bool checkedIn;
}
class Dormitory {
String id;
String building;
int floor;
int capacity;
int occupied;
}
class NotificationMsg {
String id;
String title;
String content;
DateTime time;
}
class CheckInStep {
int step;
String title;
bool completed;
}
逻辑关系
- Student -> Dormitory (多对一)
- Student -> CheckInStep (一对多)
- Student -> NotificationMsg (多对多)
开发核心代码解析
当前展示的是系统首页 IntroPage,属于控制面板入口页。
1. 页面入口
class IntroPage extends StatefulWidget {
const IntroPage({super.key});
@override
State<IntroPage> createState() => _IntroPageState();
}
解析:
- 使用
StatefulWidget,因为后续会涉及登录状态、宿舍数据刷新、通知动态更新。
2. 页面骨架
return Scaffold(
body: SafeArea(
child: Column(
children: [
_buildHeader(theme),
Expanded(
child: SingleChildScrollView(
// ...
),
),
],
),
),
);
解析:
| 组件 | 作用 |
|---|---|
| Scaffold | 页面基础结构 |
| SafeArea | 避免刘海屏遮挡 |
| Column | 垂直布局 |
| Expanded | 主内容自适应 |
| ScrollView | 支持滑动 |
3. 功能模块结构
主要包含以下构建方法:
_buildWelcomeSection_buildDormitoryStatus_buildDormitoryOverview_buildCheckInProcess_buildDormitoryManagement_buildNotifications_buildQuickActions
对应系统功能:
| 模块 | 系统子功能 |
|---|---|
| Welcome | 用户身份 |
| Status | 宿舍分配状态 |
| Overview | 楼栋、床位统计 |
| Process | 入住步骤 |
| Management | 报修/换宿 |
| Notifications | 系统公告 |
| QuickActions | 快捷操作 |
4. 顶部导航栏解析
Widget _buildHeader(ThemeData theme) {
return Container(
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 16),
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [
theme.colorScheme.primary,
theme.colorScheme.primaryContainer,
],
),
),
// ...
);
}
设计思想:
- 使用渐变色强化'系统首页'视觉权重。
theme.colorScheme→ 跨平台自适应(鸿蒙深色模式)。
登录与注册按钮
Row(
children: [
Container(
padding: const EdgeInsets.all(8),
margin: const EdgeInsets.only(right: 12),
child: const Text('登录'),
),
Container(
padding: const EdgeInsets.all(8),
child: Text('注册', style: TextStyle(color: theme.colorScheme.primary)),
),
],
)
后续可接入:
- Harmony Account Kit
- 校园统一身份认证
系统整体设计
[学生端 Flutter] | v [API Gateway] | ---------------------------------
| 学生服务 | 宿舍服务 | 通知服务 |
---------------------------------
| [MySQL / Redis]
心得
- Flutter 在鸿蒙上运行非常流畅。
- 组件化 UI + 业务解耦让维护成本极低。
- 数据结构是系统可扩展性的核心。
- Harmony 分布式能力可用于跨设备通知。
总结
DormOne 是一个以数据为核心、以流程为导向、以跨端为支撑的智慧校园系统。通过 Flutter × HarmonyOS 6.0 的组合,实现了:
一次开发,多端运行;一份数据,全局可视;一个系统,覆盖全流程。
本文围绕 DormOne 新生宿舍管理系统,系统性地阐述了基于 Flutter × HarmonyOS 6.0 的跨端架构设计思路,从业务背景、整体架构、核心数据结构到关键 UI 代码实现,完整展示了一个智慧校园应用从设计到落地的全过程。通过组件化页面结构、清晰的数据模型以及分层解耦的系统架构,DormOne 不仅解决了传统宿舍管理中信息割裂、流程不透明、响应滞后的问题,也为后续功能扩展和多终端协同提供了稳定基础。实践证明,Flutter 的高效跨平台能力与 HarmonyOS 的分布式生态深度结合,为高校信息化系统提供了一种高可维护、高可扩展、低成本的新型技术路径,具有良好的工程价值与推广意义。


