编辑工具设定
你可以使用任意文本编辑器,结合我们的命令行工具来开发 Flutter 应用。然而,我们推荐使用我们的编辑器插件以获取更好的开发体验。这些插件提供了代码补全、代码高亮、widget 辅助编辑的功能,以及为项目的运行和调试提供支持等。
You can build apps with Flutter using any text editor combined with our command-line tools. However, we recommend using one of our editor plugins for an even better experience. These plugins provide you with code completion, syntax highlighting, widget editing assists, run & debug support, and more.
参考以下步骤为 Android Studio、IntelliJ 或者 VS Code 添加编辑器插件。如果你想使用其他的编辑器,请直接打开 下一节: 开发体验初探,来查看使用其他文本编辑器配合命令行工具来创建和运行 Flutter 应用。
Follow the steps below to add an editor plugin for Android Studio, IntelliJ, VS Code, or Emacs. If you want to use a different editor, that’s OK, skip ahead to the next step: Test drive.
安装 Android Studio
Install Android Studio
Android Studio 为 Flutter 提供了一个完整的集成开发环境。
Android Studio offers a complete, integrated IDE experience for Flutter.
-
Android Studio,2020.3.1 (Arctic Fox) 或之后的版本
Android Studio, version 2020.3.1 (Arctic Fox) or later
同时, 你也可以使用 IntelliJ:
Alternatively, you can also use IntelliJ:
-
IntelliJ IDEA Community,2021.2 或之后的版本
IntelliJ IDEA Community, version 2021.2 or later
-
IntelliJ IDEA Ultimate,2021.2 或之后的版本
IntelliJ IDEA Ultimate, version 2021.2 or later
安装 Flutter 和 Dart 插件
Install the Flutter and Dart plugins
请参考下面不同平台的安装指南:
The installation instructions vary by platform.
Mac
安装过程如下:
Use the following instructions for macos:
-
打开 Android Studio。
Start Android Studio.
-
打开插件设置(在 v3.6.3.0 以上的系统打开 Preferences > Plugins)。
Open plugin preferences (Preferences > Plugins as of v3.6.3.0 or later).
-
然后选择 Flutter 插件并点击 安装。
Select the Flutter plugin and click Install.
-
当弹出安装 Dart 插件提示时,点击 Yes。
Click Yes when prompted to install the Dart plugin.
-
当弹出重新启动提示时,点击 Restart。
Click Restart when prompted.
Linux 或者 Windows 平台
Linux or Windows
参考使用下面介绍的步骤:
Use the following instructions for Linux or Windows:
-
打开插件偏好设置 (位于 File > Settings > Plugins)
Open plugin preferences (File > Settings > Plugins).
-
选择 Marketplace (扩展商店),选择 Flutter plugin 然后点击 Install (安装)。
Select Marketplace, select the Flutter plugin and click Install.
安装 VS Code
Install VS Code
VS Code 是一个可以运行和调试 Flutter 的轻量级编辑器。
VS Code is a lightweight editor with complete Flutter app execution and debug support.
安装 Flutter 和 Dart 插件
Install the Flutter and Dart plugins
-
打开 VS Code。
Start VS Code.
-
打开 View > Command Palette…。
Invoke View > Command Palette….
-
输入「install」,然后选择 Extensions: Install Extensions。
Type “install”, and select Extensions: Install Extensions.
-
在扩展搜索输入框中输入「flutter」,然后在列表中选择 Flutter 并单击 Install。此过程中会自动安装必需的 Dart 插件。
Type “flutter” in the extensions search field, select Flutter in the list, and click Install. This also installs the required Dart plugin.
-
点击 Reload to Activate 以重新启动 VS Code。
Click Reload to Activate to reload VS Code.
通过 Flutter Doctor 命令验证是否安装成功
Validate your setup with the Flutter Doctor
-
打开 View > Command Palette…。
Invoke View > Command Palette….
-
输入 “doctor”,选择 Flutter: Run Flutter Doctor。
Type “doctor”, and select the Flutter: Run Flutter Doctor.
-
打开 OUTPUT 面板查看是否有错误,确保在不同的输出选项 (Output Options) 的下拉列表中选择了 Flutter。
Review the output in the OUTPUT pane for any issues. Make sure to select Flutter from the dropdown in the different Output Options.
安装 Emacs 编辑器
Install Emacs
Emacs 是一个轻量级的编辑器,支持 Flutter 和 Dart。
Emacs is a lightweight editor with support for Flutter and Dart.
安装 lsp-dart 包
Install the lsp-dart package
关于如何安装和使用 lsp-dart 包,可以查看 lsp-dart 文档。
For information on how to install and use the package, see the lsp-dart documentation.