Dart 开发者工具

Dart DevTools is a suite of debugging and performance tools for Dart and Flutter.

Using DevTools with a Flutter app

For details on using DevTools with a Flutter app, see the Flutter DevTools documentation.

Using DevTools with a command-line app

You can use DevTools to perform source-level debugging or to view general log and diagnostics information for a running command-line app.

1. Install DevTools

Use pub to install or update DevTools:

$ pub global activate devtools

2. Launch the DevTools server

Once you have DevTools, use the devtools command to run the local web server for DevTools:

$ pub global run devtools
Serving DevTools at http://127.0.0.1.9100

3. Start the target app

Use the dart --observe command to execute the main file for the Dart command-line app that you want to debug or observe:

$ cd path/to/dart/app
$ dart --observe main.dart

Observatory listening on http://127.0.0.1:8181/wYDP3x9mvbw=/

Note the “listening” URL. You’ll need this URL in the next step.

4. Open DevTools and connect to the target app

  1. Open Chrome browser window and navigate to http://localhost:9100.
  2. Paste the “listening” URL into the text field under Connect to a running app, and click the Connect button.

DevTools connection dialog