Overview
DevTools provides:- Debugger - Set breakpoints, step through code, inspect variables
- Performance - CPU profiling, timeline views, frame analysis
- Memory - Heap snapshots, memory allocation tracking
- Network - HTTP request/response monitoring
- Logging - Application logging and diagnostics
- App Inspector - Widget tree inspection (Flutter)
Usage
Starting DevTools
Standalone Mode
Launch DevTools without connecting to an app:Connect to Running App
Connect DevTools to a running application:Command-Line Options
Server Options
Connection Options
Advanced Options
Features
Debugger
Debug running Dart applications: Features:- Set breakpoints
- Step through code (step in, step over, step out)
- Inspect variables and call stacks
- Evaluate expressions
- View console output
-
Run app with debugger enabled:
-
Open DevTools:
- Navigate to the Debugger tab
- Set breakpoints by clicking line numbers
- Step through code using controls
Performance Profiling
Analyze CPU performance: Features:- CPU flame charts
- Timeline events
- Frame rendering analysis
- Bottom-up and call tree views
- Open DevTools Performance tab
- Click Record to start profiling
- Perform the operations you want to profile
- Click Stop to end profiling
- Analyze the flame chart and call tree
Memory Profiling
Track memory allocation and usage: Features:- Heap snapshots
- Memory allocation timeline
- Object retention analysis
- Memory leak detection
- Open DevTools Memory tab
- Take a snapshot:
- Click Snapshot to capture current memory state
- Analyze objects:
- View object counts by class
- Inspect object references
- Compare snapshots to find leaks
Network Monitoring
Monitor HTTP traffic: Features:- Request/response logging
- Headers inspection
- Response body viewing
- Timing information
- Uses
dart:ioHttpClient orpackage:http - Automatically tracks HTTP requests
- Open DevTools Network tab
- Make HTTP requests in your app
- Inspect requests in the network panel
- View headers, body, and timing
Logging
View application logs and diagnostics: Features:- Structured logging
- Log level filtering
- Search and filter logs
- Export logs
Connecting to Apps
Local Development
Remote Debugging
Connect to remote applications:Production Debugging
Warning: Only enable VM service in production with proper security:Integration
VS Code
DevTools integrates with VS Code:- Install Dart extension
- Run app in debug mode:
F5 - Click Open DevTools in debug toolbar
IntelliJ IDEA / Android Studio
DevTools integrates with IntelliJ:- Run app in debug mode
- Click Open DevTools in debug panel
- Or use Run → Open DevTools
Chrome DevTools Extension
Use Chrome DevTools for Dart:Advanced Usage
Custom DevTools Build
Use a custom DevTools build:Headless Mode
Run DevTools server without opening browser:DDS (Dart Development Service)
DevTools uses DDS for enhanced debugging:- Automatic connection pooling
- Service extensions
- Enhanced logging
--observe.
Performance Tips
CPU Profiling
-
Profile mode: Use
--profileflag for accurate profiling - Focus on hot paths: Look for wide bars in flame charts
- Bottom-up view: Find most expensive functions
- Export profiles: Save profiles for later analysis
Memory Profiling
- Baseline snapshots: Take snapshot before operations
- Force GC: Trigger garbage collection before snapshots
- Compare snapshots: Find memory leaks
- Filter by class: Focus on specific object types
Network Optimization
- Monitor request sizes: Large payloads affect performance
- Check timing: Identify slow requests
- Batch requests: Reduce number of HTTP calls
- Cache responses: Avoid redundant requests
Examples
Debug a CLI Application
Profile Performance
Find Memory Leaks
Troubleshooting
DevTools Won’t Start
Can’t Connect to App
Performance Issues
- Close unused tabs in DevTools
- Disable source maps if not debugging
- Clear timeline data regularly
- Use headless mode for server-only usage
See Also
- DevTools Documentation - Official DevTools guide
- VM Service Protocol - VM service specification
- Debugging Dart - Debugging techniques