This page describes the fastest way to build DevTools with the goal to use it. Do not mix this setup with development environment. If you want to make code changes, follow contributing guidance.
You may want to build DevTools locally to:
-
Try experimental features
-
Run DevTools on Flutter Desktop instead of Flutter Web. This will eliminate issues like the browser memory limit, for example, to be able to analyze heap snapshots of large applications.
These steps are tested for Mac and may require adjustments for other platforms. Contributions to make these instructions more platform-agnostic are welcome.
Configure Dart & Flutter on your local machine.
After doing so, typing which flutter and which dart (or where.exe flutter and where.exe dart for Windows)
into your terminal should print the path to your Flutter and Dart executables.
-
Ensure you have a clone of the DevTools repository on your machine. This can be a clone of
flutter/devtoolsor a clone of a DevTools fork from your own Github account. You may want to fork Devtools to your own Github account if you plan to contribute to the project.In your terminal, navigate to a directory where you want to clone DevTools:
cd some/directory. This folder must not already contain a folder named 'devtools'.If you do not already have an SSH key set up for your machine, you may need to generate a new SSH key to connect to Github.
To clone
flutter/devtools:git clone git@github.com:flutter/devtools.git
To clone your fork of flutter/devtools:
- Fork the DevTools repo to your own Github account.
- Clone your fork of the DevTools repo:
git clone git@github.com:<your_github_account>/devtools.git
- Make sure to configure Git to keep your fork in sync with the upstream DevTools repo.
-
Ensure that you have access to the
dtexecutable by:- Running
flutter pub geton thedevtools/tooldirectory - Adding the
devtools/tool/binfolder to yourPATHenvironment variable:- MacOS Users
-
add the following to your
~/.zshrcfile (or~/.bashrc,~/.bash_profileif you use Bash), replacing<DEVTOOLS_DIR>with the absolute path to your DevTools repo:export PATH=$PATH:<DEVTOOLS_DIR>/tool/bin
-
- Windows Users
- Open "Edit environment variables for your account" from Control Panel
- Locate the
Pathvariable and click Edit - Click the New button and paste in
<DEVTOOLS_DIR>/tool/bin, replacing<DEVTOOLS_DIR>with the absolute path to your DevTools repo.
- MacOS Users
Explore the commands and helpers that the
dtprovides by runningdt -h. - Running
To ensure your DevTools repository is up to date and ready to build, run the following from the
devtools directory (this will delete any local changes you have made to your DevTools clone):
git checkout master
git reset --hard origin/master # (use upstream/master instead if you cloned a fork of DevTools)
dt update-flutter-sdk
dt pub-get --only-main --upgrade-
From the main
devtools/packages/devtools_appdirectory, run the following, where<platform>is one ofchrome,macos, orwindowsdepending on which platform you are targeting:../../tool/flutter-sdk/bin/flutter run --release -d <platform>
- Add
--dart-define=enable_experiments=trueto enable experimental features.
- Add
-
Run the application that you want to debug or profile with DevTools.
-
Paste the VM Service URL of your application into the DevTools connect dialog. See this example.