Dart 开发者工具
Dart DevTools is a suite of debugging and performance toolsfor Dart and Flutter.
Using DevTools with a Flutter app
For details on using DevTools with a Flutter app, see the FlutterDevTools documentation.
Using DevTools with a command-line app
You can use DevTools to perform source-level debugging or to view general log and diagnostics informationfor 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
commandto run the local web server for DevTools:
$ pub global run devtools
Serving DevTools at http://127.0.0.1.9100
备忘: If the system cache bin
directory is in your path, then you can just run devtools
, without pub global run
.
3. Start the target app
Use the dart —observe
command to execute the main filefor 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.
重要说明: This URL contains a security token and is different for each run of your app. If you stop your app and rerun it, then you need to connect to DevTools with the new “listening” URL.
4. Open DevTools and connect to the target app
- Open Chrome browser window and navigate to
http://localhost:9100
. - Paste the “listening” URL into the text fieldunder Connect to a running app, and click the Connect button.