From Monarch you can enable several options to visually debug your stories:
- Slow animations: Run animations 5 times slower to help fine-tune them.
- Show guidelines: Overlay guidelines to assist with fixing layout issues.
- Show baselines: Show baselines, which are used for aligning text. Can be useful for checking if text is aligned.
- Highlight repaints: Show borders that change color when elements repaint. Useful for finding unnecessary repaints.
- Highlight oversized images: Highlights images that are using too much memory by inverting colors and flipping them.
For more information, see Flutter's Visual Debugging documentation.
DevTools is a suite of performance and debugging tools provided by the Flutter team. You can launch DevTools from Monarch so you can further inspect, diagnose and debug your stories and widgets.
DevTools has many features you can explore to see how they affect your stories. The ones you may find most useful are "Select Widget Mode" and the "Details Tree".
DevTools will not show your widgets under its Widget tree on the left side or under the Layout Explorer tab. Monarch renders your stories and widgets dynamically so DevTools doesn't have enough diagnostics information to generate the widget tree. To see your widgets in DevTools use "Select Widget Mode" as described below.
After you click "Select Widget Mode", you can go to Monarch and select a widget on your story. You can then go to the "Details Tree" to see useful information about the selected widget’s properties, render object, and children.
Debug your widgets source code
With Monarch and DevTools you can debug your widgets source code in isolation, without running the full app.
To debug a widget:
- From Monarch, launch DevTools.
- In DevTools, go to the Debugger tab.
- Click Libraries (top right) or use the hot key command
⌘ + Por
ctrl + P.
- Search for your widget's source file or story source file.
- To set a breakpoint, click the left margin (the line number ruler) in the source area.
- Go to Monarch, and select a story that exercises the selected source file at the breakpoint location.
- The DevTools debugger will pause at your breakpoint.
- Now, you can inspect the call stack, variables and step through the code.
- Click Resume when you are done to let Monarch continue its normal operation.
For more information, see the DevTool's Debugger documentation.