Module 6
Topic 6

DevTools

A suite of performance and debugging tools for Dart and Flutter — your essential toolkit for building high-quality apps.

DevTools Documentation DevTools Guide
What Is DevTools?

DevTools is a suite of performance and debugging tools for Dart and Flutter. It's an essential part of your Flutter development workflow, helping you diagnose issues , profile performance , and debug your applications effectively.

💡 Key Insight

DevTools is not a replacement for your IDE — it's a complement . You use DevTools alongside your existing IDE or command-line workflow to get deep insights into your app's behavior.

🔍
Widget Inspector
Inspect UI layout and state
Find layout issues, inspect widgets
📊
Performance
Diagnose UI jank and frame issues
Find slow frames, optimize rendering
🧠
CPU Profiler
Profile CPU usage and call stacks
Find expensive functions, optimize code
🌐
Network
Monitor network requests
Debug API calls, check response times
💾
Memory
Debug memory issues and leaks
Find memory leaks, optimize usage
🐛
Debugger
Source-level debugging
Set breakpoints, step through code
Launching DevTools

There are several ways to launch DevTools depending on your workflow:

💻 Command Line
Run flutter pub global run devtools or use the link from flutter run output
📝 Android Studio / IntelliJ
Click the Open DevTools button in the Flutter inspector
📝 VS Code
Run the Flutter: Open DevTools command or click the status bar item
🌐 Browser
Navigate to http://localhost:9100 (or the port shown in your terminal)

💡 Pro Tip: Always Use Profile Mode

For accurate performance measurements, always run your app in profile mode ( flutter run --profile ). Debug mode includes extra assertions and checks that slow down performance and give misleading results.

Performance Tab

The Performance tab helps you diagnose UI jank and frame rendering issues. It's your first stop when your app feels slow or stuttery.

📊 What You Can See

  • Frame timing – See each frame's duration (green = good, red = jank)
  • UI thread – Time spent building widgets
  • Raster thread – Time spent rendering pixels
  • CPU usage – Overall CPU utilization
  • Timeline events – Detailed breakdown of what happened in each frame

✅ Performance Checklist

  • Check frame timing – Look for frames > 16ms
  • Check UI thread – Look for expensive widget builds
  • Check raster thread – Look for expensive rendering operations
  • Check for saveLayer() – Enable checkerboard rendering
  • Check for rebuilds – Use widget rebuild tracking
Widget Inspector

The Widget Inspector lets you visualize and explore the widget tree of your running app. It's invaluable for understanding your app's structure and debugging layout issues.

🔍 What You Can Do

  • Select widgets – Click on widgets in the app or the tree
  • View properties – See all properties of a selected widget
  • See layout – Visualize how widgets are laid out
  • Track rebuilds – See which widgets are rebuilding frequently
  • Find widget – Search for widgets by type or property

✅ Widget Inspector Tips

  • Show widget rebuilds – Identify widgets that rebuild too often
  • Show layout overflow – Find layout errors and overflow issues
  • Enable slow animations – Slow down animations for debugging
  • Use the selection tool – Click on widgets in your app to select them
Memory Tab

The Memory tab helps you debug memory issues and find memory leaks in your application.

💾 What You Can See

  • Memory usage – Real-time memory consumption
  • GC events – Garbage collection activity
  • Heap snapshots – Detailed memory snapshots
  • Memory allocation – Where memory is being allocated

✅ Memory Best Practices

  • Dispose controllers – Always dispose AnimationController, StreamController
  • Use lazy loading – Only load what you need, when you need it
  • Avoid large objects – Break up large widgets and images
  • Use const widgets – Reduces memory allocation
  • Monitor GC frequency – Excessive GC means too much allocation
CPU Profiler

The CPU Profiler helps you identify which functions are taking the most CPU time, making it easier to optimize your code.

🧠 What You Can Do

  • Record CPU samples – Capture CPU usage over time
  • View call stacks – See which functions are called
  • Flame chart – Visualize CPU usage over time
  • Bottom-up view – See which functions consume the most CPU

✅ CPU Profiling Tips

  • Profile in release mode – For accurate results
  • Focus on expensive operations – Look for functions > 1% of CPU
  • Check the flame chart – Visually identify bottlenecks
  • Compare profiles – Profile before and after optimizations
Step-by-Step Debugging with DevTools

Follow these steps to debug common issues using DevTools:

1.
Launch DevTools – Run in profile mode and open DevTools
2.
Check performance – Look for frames > 16ms in the Performance tab
3.
Inspect widgets – Use the Widget Inspector to check rebuild frequency
4.
Profile CPU – Record a CPU profile and find expensive functions
5.
Check memory – Look for memory leaks or excessive allocations
6.
Debug network – Check API calls and response times
7.
Fix and re-measure – Apply fixes and profile again
Common Mistakes
❌ Mistake 1: Profiling in debug mode

Debug mode includes extra assertions that slow down performance and give misleading results. Always use profile mode for performance analysis.

✅ Correct: Use profile mode

Run flutter run --profile for accurate performance measurements.

❌ Mistake 2: Not checking the raster thread

Many performance issues are in the raster thread (rendering), not the UI thread (building). Check both.

✅ Correct: Check both UI and raster threads

Look at both the UI thread (build) and raster thread (render) in the Performance tab.

❌ Mistake 3: Ignoring memory leaks

Not disposing controllers and streams leads to memory leaks that degrade performance over time.

✅ Correct: Dispose of resources

Always call dispose() on AnimationController, StreamController, and other disposable objects.

❌ Mistake 4: Not using DevTools at all

Guessing about performance issues is inefficient. Use DevTools to find the actual bottlenecks.

✅ Correct: Use DevTools regularly

Make DevTools part of your development workflow. Profile early and often.

Resources

📚 Learning Resources

🔗 Related Lessons

🎯 Key Takeaway

DevTools is your essential toolkit for building high-quality Flutter apps. Use the Performance tab to diagnose jank, the Widget Inspector to understand your UI, the CPU Profiler to find expensive operations, and the Memory tab to catch leaks. Always profile in release mode and make DevTools a regular part of your development workflow. With DevTools, you can build faster, smoother, and more reliable Flutter applications.