Flutter桌面配置Skill flutter-desktop-config

本技能用于配置Flutter框架以支持Windows、macOS和Linux等桌面平台开发。核心功能包括启用桌面支持、设置平台通道以实现Dart与原生代码(如Swift、C++)的通信、配置窗口属性、菜单栏、系统托盘、应用图标与元数据,以及生成MSIX、DMG、DEB等平台特定的安装包。适用于需要将Flutter应用扩展到桌面端的跨平台开发者。 关键词:Flutter桌面开发,跨平台应用,平台通道,原生集成,窗口配置,桌面打包,Dart,Windows,macOS,Linux

移动开发 0 次安装 0 次浏览 更新于 2/25/2026

name: flutter-desktop-config description: 为桌面平台配置Flutter,包括平台通道和原生集成 allowed-tools: Read, Write, Edit, Bash, Glob, Grep tags: [flutter, dart, 跨平台, 桌面, ui]

flutter-desktop-config

为桌面平台(Windows, macOS, Linux)配置Flutter,包括平台通道、原生集成和平台特定配置。

能力

  • 启用Flutter桌面支持
  • 为原生代码配置平台通道
  • 设置平台特定的运行器
  • 配置窗口管理
  • 设置菜单栏和系统托盘
  • 配置应用图标和元数据
  • 设置MSIX/DMG/DEB打包
  • 配置插件支持

输入模式

{
  "type": "object",
  "properties": {
    "projectPath": { "type": "string" },
    "platforms": { "type": "array", "items": { "enum": ["windows", "macos", "linux"] } },
    "windowConfig": { "type": "object" },
    "nativeChannels": { "type": "array" }
  },
  "required": ["projectPath"]
}

平台通道示例

// Dart 端
class NativeService {
  static const platform = MethodChannel('com.example/native');

  Future<String> getSystemInfo() async {
    return await platform.invokeMethod('getSystemInfo');
  }
}
// macOS (Swift)
let controller = FlutterViewController()
let channel = FlutterMethodChannel(name: "com.example/native",
                                   binaryMessenger: controller.engine.binaryMessenger)
channel.setMethodCallHandler { call, result in
    if call.method == "getSystemInfo" {
        result(ProcessInfo.processInfo.operatingSystemVersionString)
    }
}

相关技能

  • cross-platform-test-matrix
  • desktop-build-pipeline 流程