flutter3.27+bitsdojo_window电脑端仿微信Exe应用

320 阅读3分钟

2025最新基于flutter3.27+dart3.6+getx+bitsdojo_window+media_kit+system_tray仿微信桌面客户端聊天EXE实例。包含聊天、联系人、收藏、朋友圈、小视频、我的等模块。

未标题-0.png

p1.gif

实现技术

  • 编码工具:VScode
  • 跨平台框架:Flutter3.27.1+Dart3.6.0
  • 窗口管理:bitsdojo_window: ^0.1.6
  • 托盘图标:system_tray: ^2.0.3
  • 路由/状态管理:get: ^4.7.2
  • 本地存储:get_storage: ^2.1.1
  • 图片预览:photo_view: ^0.15.0
  • 网址预览:url_launcher: ^6.3.1
  • 视频组件:media_kit: ^1.2.0
  • 文件选择器:file_picker: ^10.2.0
  • 富文本编辑器:fleather: ^1.22.0

未标题-4.png

p3.gif

项目使用 bitsdojo_window 插件进行窗口管理。支持无边框窗口,窗口尺寸大小,自定义右上角 系统操作按钮(最大化/最小化/关闭)。

pub-web.flutter-io.cn/packages/bi…

使用 system_tray 插件管理系统托盘。

pub-web.flutter-io.cn/packages/sy…

p7.gif

项目框架结构

360截图20250721071130837.png

项目布局结构

010360截图20250720105933877.png

布局分为菜单栏+侧边栏+右侧主区域三个模块。

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,
                  ),
                ),
              ],
            ),
          ),
        ],
      ),
    );
  }
}

001360截图20250720100500795.png

002360截图20250720101555076.png

003360截图20250720101914822.png

003360截图20250720102029444.png

004360截图20250720102151479.png

004360截图20250720102346949.png

005360截图20250720102504267.png

006360截图20250720102919221.png

007360截图20250720103353516.png

flutter3+bitsdojo_window无边框窗口

Widget build(BuildContext context){
  return Row(
    children: [
      Container(
        child: widget.leading,
      ),
      Visibility(
        visible: widget.minimizable,
        child: MouseRegion(
          cursor: SystemMouseCursors.click,
          child: SizedBox(
            width: 32.0,
            height: 36.0,
            child: MinimizeWindowButton(colors: buttonColors, onPressed: handleMinimize,),
          )
        ),
      ),
      Visibility(
        visible: widget.maximizable,
        child: MouseRegion(
          cursor: SystemMouseCursors.click,
          child: SizedBox(
            width: 32.0,
            height: 36.0,
            child: isMaximized ?
            RestoreWindowButton(colors: buttonColors, onPressed: handleMaxRestore,)
            :
            MaximizeWindowButton(colors: buttonColors, onPressed: handleMaxRestore,),
          ),
        ),
      ),
      Visibility(
        visible: widget.closable,
        child: MouseRegion(
          cursor: SystemMouseCursors.click,
          child: SizedBox(
            width: 32.0,
            height: 36.0,
            child: CloseWindowButton(colors: closeButtonColors, onPressed: handleExit,),
          ),
        ),
      ),
      Container(
        child: widget.trailing,
      ),
    ],
  );
}
// 监听窗口尺寸变化
@override
void didChangeMetrics() {
  super.didChangeMetrics();
  WidgetsBinding.instance.addPostFrameCallback((_) {
    setState(() {
      isMaximized = appWindow.isMaximized;
    });
  });
}

// 最小化
void handleMinimize() {
  appWindow.minimize();
}
// 设置最大化/恢复
void handleMaxRestore() {
  appWindow.maximizeOrRestore();
}
// 关闭
void handleExit() {
  showDialog(
    context: context,
    builder: (context) {
      return AlertDialog(
        content: const Text('是否最小化至托盘,不退出程序?', style: TextStyle(fontSize: 16.0),),
        backgroundColor: Colors.white,
        shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(5.0)),
        elevation: 3.0,
        actionsPadding: const EdgeInsets.all(15.0),
        actions: [
          TextButton(
            onPressed: () {
              Get.back();
              appWindow.hide();
            },
            child: const Text('最小化至托盘', style: TextStyle(color: Colors.blue),)
          ),
          TextButton(
            onPressed: () {
              Get.back();
              appWindow.close();
            },
            child: const Text('退出系统', style: TextStyle(color: Colors.red),)
          ),
        ],
      );
    }
  );
}

p8-1.gif

flutter3短视频模块

006360截图20250720103145399.png

底部mini播放进度条支持拖拽、点击播放位置功能。

// mini播放进度条
Positioned(
  bottom: 10.0,
  left: 6.0,
  right: 6.0,
  child: Visibility(
    visible: videoIndex == index && position > Duration.zero,
    child: Listener(
      child: SliderTheme(
        data: SliderThemeData(
          trackHeight: sliderDraging ? 6.0 : 2.0,
          thumbShape: RoundSliderThumbShape(enabledThumbRadius: 4.0), // 调整滑块的大小
          // trackShape: RectangularSliderTrackShape(), // 使用矩形轨道形状
          overlayShape: RoundSliderOverlayShape(overlayRadius: 0), // 去掉Slider默认上下边距间隙
          inactiveTrackColor: Colors.white24, // 设置非活动进度条的颜色
          activeTrackColor: Colors.white, // 设置活动进度条的颜色
          thumbColor: Colors.white, // 设置滑块的颜色
          overlayColor: Colors.transparent, // 设置滑块覆盖层的颜色
        ),
        child: Slider(
          value: sliderValue,
          onChanged: (value) async {
            // debugPrint('当前视频播放时间$value');
            setState(() {
              sliderValue = value;
            });
            // 跳转播放时间
            await player.seek(duration * value.clamp(0.0, 1.0));
          },
          onChangeEnd: (value) async {
            setState(() {
              sliderDraging = false;
            });
            // 继续播放
            if(!player.state.playing) {
              await player.play();
            }
          },
        ),
      ),
      onPointerMove: (e) {
        setState(() {
          sliderDraging = true;
        });
      },
    ),
  ),
)

综上就是flutter3实战微信客户端聊天exe项目的一些知识分享。

最新Flutter3.32+Dart3仿微信App聊天实例|flutter3仿微信朋友圈

基于uniapp+vue3+uvue短视频+聊天+直播app系统

基于uniapp+vue3+deepseek+markdown跨三端搭建app版流式输出AI模板

vue3.5+deepseek+arco+markdown搭建web网页版流式输出AI模板

基于tauri2.0+vue3.5+deepseek+arco搭建windows版流式输出AI系统

vue3仿Deepseek/ChatGPT流式聊天AI界面,对接deepseek/OpenAI API

Flutter3.27深度融合仿抖音app短视频+直播+聊天实例

原创electron31+vite5.x+elementPlus桌面端后台管理系统

自研tauri2.0+vite6.x+vue3+rust+arco-design桌面版os管理系统Tauri2-ViteOS

自研tauri2.0+vite5+vue3+element-plus电脑版exe聊天系统Vue3-Tauri2Chat