爆肝两周!基于flutter3.41+dart3.11深度仿写微信客户端Exe聊天系统。
技术知识点
- 编辑器:vscode
- 框架技术:flutter3.41+dart3.11
- 弹窗组件:showDialog/SimpleDialog/showModalBottomSheet/AlertDialog
- 图片预览:photo_view^0.15.0
- 存储组件:get_storage^2.1.1
- 下拉刷新:easy_refresh^3.5.0
- 通讯录侧边滑动:scrollable_positioned_list^0.3.8
- toast提示:toast^0.3.0
- 网址预览组件:url_launcher^6.3.1
项目结构目录
基于最新版Flutter3.41跨平台框架构建项目模板。
2026实战!Flutter3.41打造桌面级仿微信exe聊天系统 - bilibili
项目入口配置
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:bitsdojo_window/bitsdojo_window.dart';
import 'package:get/get.dart';
import 'package:get_storage/get_storage.dart';
import 'package:media_kit/media_kit.dart';
import 'package:system_tray/system_tray.dart';
import 'utils/common.dart';
// 公共布局模板
import 'layouts/index.dart';
// 路由管理
import 'router/index.dart';
void main() async {
// 初始化get_storage存储类
await GetStorage.init();
// 初始化media_kit视频套件
WidgetsFlutterBinding.ensureInitialized();
MediaKit.ensureInitialized();
initSystemTray();
runApp(const MyApp());
// 初始化bitsdojo_window窗口
doWhenWindowReady(() {
appWindow.size = const Size(850, 620);
appWindow.minSize = const Size(700, 500);
appWindow.alignment = Alignment.center;
appWindow.title = 'Flutter3-WinChat';
appWindow.show();
});
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return GetMaterialApp(
title: 'FLUTTER3 WINCHAT',
debugShowCheckedModeBanner: false,
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Color(0xFF07C160)),
useMaterial3: true,
// 修正windows端字体粗细不一致
fontFamily: Platform.isWindows ? 'Microsoft YaHei' : null,
),
home: const Layout(),
// 初始路由
initialRoute: Common.isLogin() ? '/index' :'/login',
// 路由页面
getPages: routes,
);
}
}
// 创建系统托盘图标
Future<void> initSystemTray() async {
String trayIco = 'assets/images/tray.ico';
SystemTray systemTray = SystemTray();
// 初始化系统托盘
await systemTray.initSystemTray(
title: 'system-tray',
iconPath: trayIco,
);
// 右键菜单
final Menu menu = Menu();
await menu.buildFrom([
MenuItemLabel(label: '打开主界面', onClicked: (menuItem) => appWindow.show()),
MenuItemLabel(label: '隐藏窗口', onClicked: (menuItem) => appWindow.hide()),
MenuItemLabel(label: '设置中心', onClicked: (menuItem) => Get.toNamed('/setting')),
MenuItemLabel(label: '关于', onClicked: (menuItem) => {}),
MenuItemLabel(label: '退出', onClicked: (menuItem) => appWindow.close()),
]);
await systemTray.setContextMenu(menu);
// 右键事件
systemTray.registerSystemTrayEventHandler((eventName) {
debugPrint('eventName: $eventName');
if (eventName == kSystemTrayEventClick) {
Platform.isWindows ? appWindow.show() : systemTray.popUpContextMenu();
} else if (eventName == kSystemTrayEventRightClick) {
Platform.isWindows ? systemTray.popUpContextMenu() : appWindow.show();
}
});
}
项目整体采用 bitsdojo_window 进行窗口管理。支持无边框窗口,窗口尺寸大小,自定义系统操作按钮(最大化/最小化/关闭)。
system_tray 插件管理系统托盘图标。
flutter3通用布局模板
整体布局分为菜单栏+侧边栏+右侧主区域三个模块。
class Layout extends StatefulWidget {
const Layout({
super.key,
this.activitybar = const Activitybar(),
this.sidebar,
this.child,
this.showSidebar = true,
});
final Widget? activitybar; // 左侧菜单栏
final Widget? sidebar; // 侧边栏
final Widget? child; // 右侧内容区域
final bool showSidebar; // 是否显示侧边栏
@override
State<Layout> createState() => _LayoutState();
}
class _LayoutState extends State<Layout> {
// 置顶窗口
bool winTopMost = false;
@override
void initState() {
super.initState();
}
@override
void dispose() {
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.grey[100],
body: Flex(
direction: Axis.horizontal,
children: [
// 左侧菜单栏
MoveWindow(
child: widget.activitybar
),
// 侧边栏
Visibility(
visible: widget.showSidebar,
child: SizedBox(
// ...
),
),
// 主体容器
Expanded(
child: Column(
children: [
// 导航栏
WindowTitleBarBox(
child: Row(
children: [
Expanded(
child: MoveWindow(),
),
// 右上角操作按钮组
Winbtn(
// ...
),
],
),
),
// 内容区域
Expanded(
child: Container(
child: widget.child,
),
),
],
),
),
],
),
);
}
}
爆肝flutter3.41+dart3.11+getx+dio仿写deepseek智能ai应用app
自研flutter3.38实战抖音app短视频+聊天+直播商城系统
基于electron38+vite7+vue3 setup+elementPlus电脑端仿微信/QQ聊天软件
electron38.2-vue3os系统|Vite7+Electron38+Pinia3+ArcoDesign桌面版OS后台管理
基于flutter3.32+window_manager仿macOS/Wins风格桌面os系统
2026实战uniapp+vue3+mphtml调用deepseek【小程序+安卓+H5】流式输出ai
vite8.0-webai网页版AI模板|vue3+vite8+deepseek专属web版流式ai回答助手
Electron41 + Vite8 + Vue3.5实战打造你的专属AI回答助手
2026最新款Tauri2.10+Vite7.3+DeepSeek桌面版AI系统Exe
2026最新款Vite7+Vue3+DeepSeek-V3.2+Markdown移动端流式输出AI会话
2025最新款Electron38+Vite7+Vue3+ElementPlus电脑端后台系统Exe
基于uniapp+vue3+uvue短视频+聊天+直播app系统
基于uni-app+vue3+uvui跨三端仿微信app聊天模板【h5+小程序+app】
自研tauri2.0+vite6.x+vue3+rust+arco-design桌面版os管理系统Tauri2-ViteOS