IDEs

Dart SDK

A prebuilt Dart SDK is available for IDE consumption at: //third_party/dart/tools/sdks/<linux|mac>/dart-sdk. Note that this SDK is sometimes a few days behind the version of //third_party/dart. If you require an up-to-date SDK, one gets built with Fuchsia at: //out/<build-type>/dart_host/dart-sdk.

Visual Studio Code

  1. Download and install Visual Studio Code

  2. [optional] Setup VS Code to launch from the command line

    • For Macs: To allow running VS Code from the terminal using the code command, follow the instructions here

    • For Linux and Windows: This should already be done as part of the installation

  3. Install the following extensions:

    • Dart Code: Support for programming in Dart
    • FIDL language support: Syntax highlighting support for Fuchsia's FIDL files
    • GN: Syntax highlighting for GN build files
    • Optional but helpful git extensions:
  4. Here are some helpful user settings for Dart, you can open your user settings by typing Ctrl+,:

{
  // Auto-formats your files when you save
  "editor.formatOnSave": true,

  // Don't run pub with fuchsia.
  "dart.runPubGetOnPubspecChanges": false,

  // Settings only when working in Dart
  "[dart]": {
    // Adds a ruler at 80 characters
    "editor.rulers": [
      80
    ],

    // Makes the tab size 2 spaces
    "editor.tabSize": 2,
  },
}

Troubleshooting

If you find that the IDE is unable to find imports (red squigglies) that are already correctly in your BUILD.gn dependencies, this is usually a sign that Dart analysis is not working properly in your IDE.

When this happens, try the following:

Rebuild

Delete //out and rebuild. Specifically, a release build overrides a debug build. This means that if you have a broken release build, any release build overrides a debug build. With a broken release build, no amount of correct rebuilding on debug will solve the issue until you delete //out/release-x64.

Remove pub output

  1. Delete the .packages and pubspec.lock files in your project (if present).
  2. Ensure that "dart.runPubGetOnPubspecChanges": false, is present in your VSCode preferences to prevent the files from reappearing whenever a pubspec.yaml file is edited.
  3. Reload VSCode to restart the Dart analyzer.
    1. Press Ctrl+Shift+P to open the VSCode Command Palette
    2. Select “Reload Window”