Add Windows as a target platform for Flutter from Web start

To add Windows desktop as a Flutter app target, follow this procedure.

Install and configure Visual Studio

#
  1. Allocate a minimum of 26 GB of storage for Visual Studio. Consider allocating 10 GB of storage for an optimal configuration.
  2. Install Visual Studio 2022 to debug and compile native C++ Windows code. Make sure to install the Desktop development with C++ workload. This enables building Windows app including all of its default components. Visual Studio is an IDE separate from Visual Studio Code.

检查你的开发配置

#

help 帮助

运行 Flutter doctor

#

flutter doctor 指令将检查 Windows 完整的 Flutter 开发环境的所有组件。

  1. 打开 PowerShell。

  2. 要检查所有组件的安装情况,请运行以下指令。

    PS C:> flutter doctor

由于你选择为 Windows 进行开发,因此不需要 所有 组件。如果你遵循本指南,指令结果应该类似于:

Running flutter doctor...
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.24.5, on Microsoft Windows 11 [Version 10.0.22621.3155], locale en)
[✓] Windows version (Installed version of Windows is version 10 or higher)
[!] Android toolchain - develop for Android devices
[✓] Chrome - develop for the web
[✓] Visual Studio - develop Windows apps (version 2022)
[!] Android Studio (not installed)
[✓] VS Code (version 1.95)
[✓] Connected device (1 available)
[✓] Network resources


! Doctor found issues in 2 categories.

解决 Flutter doctor 的问题

#

flutter doctor 指令返回错误时,可能是 Flutter、VS Code、Visual Studio、连接的设备或者网络资源出错。

如果 flutter doctor 指令返回这些组件中的任何一个错误,请使用 verbose 标志再次运行。

PS C:> flutter doctor -v

查看输出结果,了解可能需要安装的其他软件或者需要执行的其他任务。

如果你更改了 Flutter SDK 或其他相关组件的配置,请 再次运行 flutter doctor 来检查安装。

开始使用 Flutter 开发 Windows desktop 应用

#

恭喜你。 在安装完成所有必要条件和 Flutter SDK 后,你就可以开始开发适用于 Windows desktop 的 Flutter 应用了。

如果你要继续学习之旅,请参考以下指南: