创建新的 Flutter 应用
了解如何从命令行、不同编辑器甚至云端引导创建新的 Flutter 应用。
本页提供在你首选开发环境中引导创建新 Flutter 应用的分步说明。
要创建新 Flutter 应用,请先 set up Flutter(设置 Flutter),然后选择首选环境并遵循相应说明。
Create a new Flutter app without leaving VS Code.
Create a new Flutter app without leaving Android Studio.
Create a new Flutter app without leaving your IntelliJ-based IDE.
For agentic coding support, create a new Flutter app in Antigravity.
For maximum flexibility, create a new Flutter app from the command line.
Create a new Flutter module to embed in an existing app.
VS Code
#To create a Flutter app with VS Code and other Code OSS-based editors, you first need to install Flutter and set up VS Code for Flutter development. Then follow these steps:
Launch VS Code
Open VS Code or your preferred Code OSS-based editor.
-
Open the command palette
Go to View > Command Palette or press Cmd/Ctrl + Shift + P.
-
Find the Flutter commands
在命令面板中输入
flutter:,VS Code 应显示 Flutter 插件命令。 -
Run the new project command
选择 Flutter: New Project 命令;系统或 VS Code 可能请求文档访问权限,同意以继续。
-
Choose a template
VS Code 会提示 Which Flutter template?;根据项目类型选择模板,新建应用选 Application。
-
Select a project location
将出现文件对话框;选择或创建父目录(勿自行创建项目文件夹)。点击 Select a folder to create the project in 确认。
-
Enter a project name
VS Code 会提示输入项目名称;按
lowercase_with_underscores与 Effective Dart 输入名称,按 Enter 确认。 -
Wait for project initialization
VS Code 根据输入用
flutter create引导应用;进度常在右下角通知或 Output 面板显示。 -
Run your app
新应用应已在 VS Code 中打开;试运行请按 run and debug 步骤操作。
你已在 VS Code 中成功创建新的 Flutter 应用!更多帮助请参阅 VS Code for Flutter reference。
Android Studio
#要使用 Android Studio 创建 Flutter 应用,请先 install Flutter 并 set up Android Studio(配置 Android Studio),然后按以下步骤操作:
-
Launch Android Studio
Open Android Studio with the Dart and Flutter plugins installed.
打开已安装 Dart 与 Flutter 插件的 Android Studio。
-
Begin project creation
If you're on the IDE welcome dialog that says Welcome to Android Studio, find and click the New Flutter Project button in the center.
若在显示 Welcome to Android Studio 的欢迎对话框,点击中央的 New Flutter Project 按钮。
若已有打开的项目,可关闭或前往 File > New > New Flutter Project...。
-
Choose a project type
In the New Project dialog, under Generators in the left panel, select Flutter.
在 New Project 对话框左侧 Generators 下选择 Flutter。
-
Verify Flutter SDK setup
At the top of the right panel, ensure the Flutter SDK path value matches the location of the Flutter SDK you'd like to develop with. If not, update it by choosing or specifying the correct one.
在右侧面板顶部确保 Flutter SDK path 与欲使用的 Flutter SDK 位置一致,否则请选择或指定正确路径。
-
Configure your project
Click Next to continue to project configuration. Multiple configuration options should appear.
点击 Next 继续项目配置,将出现多个配置选项。
在 Project name 字段输入符合 lowercase_with_underscores 规范的应用名称,遵循 Effective Dart
指南。
若并非创建 application,从 Project type 下拉框选择其他模板。
若未来可能发布应用,将 Organization 字段 设为公司域名。
其他字段可保持默认或按项目需要配置。
-
Finish project creation
Once you've completed the configuration of your project, click Create to begin project initialization.
完成项目配置后,点击 Create 开始初始化。
-
Wait for workspace initialization
Android Studio will now initialize your workspace, bootstrap your project file structure, and retrieve your app's dependencies. This might take a while and can be tracked at the bottom of the window.
Android Studio 将初始化工作区、引导项目结构并获取依赖,可能耗时,可在窗口底部查看进度。
-
Run your app
Your new app should now be created and open in Android Studio. To try your new app, follow the steps to run and debug in Android Studio.
新应用应已创建并在 Android Studio 中打开;试运行请按 run and debug 步骤操作。
你已在 Android Studio 中成功创建新的 Flutter 应用!更多帮助请参阅 Android Studio for Flutter reference。
IntelliJ
#要使用 IntelliJ 或其他 JetBrains IDE 创建 Flutter 应用,请先 install Flutter 并 set up IntelliJ,然后按以下步骤操作:
-
Launch IntelliJ
Open IntelliJ IDEA or your preferred IntelliJ-based IDE by JetBrains that has the Dart and Flutter plugins installed.
-
Begin project creation
If you're on the IDE welcome dialog that says Welcome to IntelliJ IDEA, find and click the New Project button in the upper right corner.
若在 Welcome to IntelliJ IDEA 欢迎对话框,点击右上角 New Project 按钮。
If you already have a project open, either close it or go to File > New > New Project....
-
Choose a project type
In the New Project dialog, under Generators in the left panel, select Flutter.
在 New Project 对话框左侧 Generators 下选择 Flutter。
-
Verify Flutter SDK setup
At the top of the right panel, ensure the Flutter SDK path value matches the location of the Flutter SDK you'd like to develop with. If not, update it by choosing or specifying the correct one.
在右侧面板顶部确保 Flutter SDK path 与欲使用的 Flutter SDK 位置一致,否则请选择或指定正确路径。
-
Configure your project
Click Next to continue to project configuration. Multiple configuration options should appear.
点击 Next 继续项目配置,将出现多个配置选项。
在 Project name 字段输入符合 lowercase_with_underscores 规范的应用名称,遵循 Effective Dart
指南。
若并非创建 application,从 Project type 下拉框选择其他模板。
若未来可能发布应用,将 Organization 字段 设为公司域名。
其他字段可保持默认或按项目需要配置。
-
Finish project creation
Once you've completed the configuration of your project, click Create to begin project initialization.
完成项目配置后,点击 Create 开始初始化。
-
Wait for workspace initialization
IntelliJ will now initialize your workspace, bootstrap your project file structure, and retrieve your app's dependencies. This might take a while and can be tracked at the bottom of the window.
IntelliJ 将初始化工作区、引导项目结构并获取依赖,可能耗时,可在窗口底部查看进度。
-
Run your app
Your new app should now be created and open in IntelliJ. To try your new app, follow the steps to run and debug in IntelliJ.
新应用应已在 IntelliJ 中创建并打开;试运行请按 run and debug 步骤操作。
你已在 IntelliJ 中成功创建新的 Flutter 应用!更多帮助请参阅 IntelliJ for Flutter reference。
Antigravity
#To create a Flutter app with Antigravity, you first need to install and set up Antigravity as described on the Antigravity tools page. Then follow these steps:
-
Open Antigravity and create a Workspace
Launch the Antigravity IDE and create a new, sandboxed workspace for your project using the Agent Manager.
-
Use the Agent Manager
Switch to the Agent Manager interface, which is where you interact with the AI agents by using chat.
-
Write detailed prompts
Communicate your app requirements to the agent using detailed, structured prompts, much like providing instructions to a junior developer. For example, "Create a new Flutter project named my_app. Add a home screen with a list of items and a floating action button".
-
Review and approve the plan
The AI agent will generate a detailed implementation plan, including folder structure, dependencies, and steps. You can review this plan and click Proceed or provide feedback to make changes.
-
Authorize actions
The agent will ask for permission before running terminal commands (like
flutter pub addorflutter create) or accessing the browser/emulator. Review and Accept these actions to allow the agent to build the app. -
Iterate and refine
Once the initial app is generated, you can provide further prompts to add features, refine the UI, implement logic, or add persistence (for example, "Add local storage using shared_preferences").
-
Test the app
Use the integrated emulator or connect a physical device to test the app. The agent can even run tests and provide video walkthroughs of the functionality.
-
Verify code in the editor
You can switch to the standard code editor view at any time to inspect the generated Dart and Flutter files, ensuring the code quality meets your standards.
终端
#To create a Flutter app in your terminal, you first need to install and set up Flutter. Then follow these steps:
-
Open your terminal
Open your preferred method to access the command line, such as Terminal on macOS or PowerShell on Windows.
-
Navigate to the desired directory
Ensure your current working directory is the desired parent directory for your new app. Don't create the project folder, the
fluttertool will do so. -
Configure project creation
In your terminal, type out the
flutter createcommand and pass in any desired flags and options to configure your project. For example, to create an app with a minimalmain.dartfile, you can add the--emptyoption:flutter create --emptyTo learn about the available creation options, run
flutter create --helpin another terminal window. -
Enter a project name
As the only non-option argument to
flutter create, specify the directory and default name for your application. The name should follow thelowercase_with_underscoresnaming convention, following the Effective Dart guidelines.例如要创建名为
my_app的应用:flutter create my_app -
Execute the configured command
To create a project with your specified configuration, run the command you built in the previous step.
-
Wait for project initialization
The
fluttertool will now bootstrap your project's file structure and retrieve any necessary dependencies. This might take a while. -
Navigate into the project directory
Now that your project has been created, you can navigate to it in your terminal or your preferred editor. For example, with a bash shell and a project named
my_app:cd my_app -
Run your app
To try your new app, run the
flutter runcommand in your terminal and respond to its prompts to select an output device.
You've successfully created a new Flutter app in your terminal!
If you need help configuring your project or with the flutter CLI tool,
check out the Flutter CLI reference.
除非另有说明,本文档之所提及适用于 Flutter 3.44.0 版本。本页面最后更新时间:2026-06-04。查看文档源码 或者 为本页面内容提出建议。