DevTools and profiling
Flutter DevTools is a browser-based tool suite and the centre of performance work:
- Widget Inspector — the widget tree, the constraints each widget received (Layout Explorer), rebuild counts
- Performance — a frame timeline showing which frame blew the budget and whether the time went to the UI or raster thread
- CPU Profiler — which functions consume the time
- Memory — memory usage and leak hunting
- Network — outgoing requests
One requirement: measure in profile mode. Debug mode does not optimise the code and its numbers are far worse than reality — drawing conclusions from debug-mode measurements is a classic mistake.
| Symptom | Where to look | Typical cause |
|---|---|---|
| Stutter while scrolling | Performance → frame timeline | A heavy `itemBuilder`, non-const items |
| Freeze when a screen opens | CPU Profiler | Heavy synchronous computation or a large JSON parse |
| Memory grows over time | Memory → allocations | An uncancelled subscription or controller |
| A widget is unexpectedly large | Inspector → Layout Explorer | The parent passed tight constraints |
Interview tip. "How do you find a memory leak?" comes up at middle level. Structure the answer: (1) open and close the screen several times; (2) watch memory in the Memory tab fail to come back down; (3) check the allocation list for which class is accumulating instances; (4) the cause is almost always a subscription, controller or listener not cancelled in dispose(). That four-step answer is concrete and shows experience.
📚 Sources and documentation
- Flutter DevToolsofficialdocs.flutter.dev
- Performance viewofficialdocs.flutter.dev
Explains the UI/raster thread split and how to read the frame budget.
- Widget Inspectorofficialdocs.flutter.dev
- Performance best practicesofficialdocs.flutter.dev