You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

Flutter桌面应用安装流程及Windows环境下Hello World运行指南

Flutter桌面应用安装与Windows Hello World指南

Hey there! Let’s walk through getting set up for Flutter desktop development, with a focused look at Windows, plus how to launch your first Hello World app.

一、通用基础准备(全桌面平台适用)

Before diving into Windows-specific steps, let’s cover the core setup every desktop developer needs:

  • Install Flutter SDK: Grab the latest stable Flutter SDK package, extract it to a folder of your choice (like C:\flutter on Windows), then add the flutter\bin path to your system’s environment variables. This lets you run Flutter commands from any terminal window.
  • Validate your environment: Open PowerShell (Windows) or your terminal of choice, run flutter doctor. This command scans your system and tells you exactly what’s missing for Flutter development—pay attention to the output, it’s your best friend here.

二、Windows系统专属桌面安装流程

Windows has a few extra tools you’ll need to get desktop apps up and running:

  • Install Visual Studio 2022 (or 2019): You don’t need the full suite, but make sure to select the Desktop development with C++ workload during installation. Also, ensure the Windows SDK (version 10.0.17763.0 or newer) is included in this workload—it’s required for compiling Windows apps.
  • Enable Windows desktop support: In your terminal, run flutter config --enable-windows-desktop. This flips the switch to let Flutter build and run Windows apps.
  • Recheck your environment: Run flutter doctor again. You should now see a "Windows" section in the output. If there are any red X’s, follow the prompts to fix missing components (like installing the Windows SDK if you skipped it earlier).

三、Run Your First Flutter Desktop Hello World

Once your environment is set, launching a Hello World is straightforward:

  • Create a new Flutter project: Navigate to the folder where you want to store your project in PowerShell, then run flutter create my_first_desktop_app. This generates a fully functional project with support for Windows (and other platforms, if you want them).
  • Navigate to the project folder: Run cd my_first_desktop_app.
  • Launch the Windows app: Just run flutter run -d windows. Flutter will handle compiling the app, downloading any missing dependencies, and popping up a window with the default Flutter Hello World interface.
  • Pro tip for debugging: If you prefer using Visual Studio for debugging, run flutter open -d windows—this opens the Windows project in VS, where you can set breakpoints and use all the IDE’s debugging tools.

Quick Notes

  • Don’t worry if flutter doctor complains about Android/iOS setup—those are irrelevant for desktop development.
  • First run might take a minute or two (Flutter has to build a lot under the hood), but subsequent runs will be much faster.
  • Try modifying the text in lib/main.dart (look for the "You have pushed the button this many times!" line), save the file, and Flutter will automatically hot-reload the app—you’ll see the change instantly in the window.

内容的提问来源于stack exchange,提问作者ravi chandra

火山引擎 最新活动