Flutter - Using Widget Inspector in Android Studio

How to use Flutter Widget Inspector in Android Studio? Read this tutorial.

If you need to debug layout problems or you want to know the widget tree of your Flutter application, it can be done using Flutter Widget Inspector. This tutorial shows you how to use Flutter Widget Inspector with Android Studio IDE.

Using Flutter Widget Inspector in Android Studio

In order to run the widget inspector, you need to run the application first, either on an emulator or a real device.

There are some tabs on the right side of Android Studio, one of which should be Flutter Inspector. You need to click on the tab for toggling whether the Flutter Inspector window should be visible or hidden. When the window is visible, there are two tabs, Widgets and Render Tree.

On the Widgets tab, you can see the list of widgets in a tree structure. Selecting a widget shows the properties and details of the widget.

Flutter - Widget Inspector - Widgets

 

The RenderTree tab displays the render tree of the widgets. It allows you to understand how Flutter converts widgets into RenderObjects.

Flutter - Widget Inspector - Render Tree

On the top of the Widget Inspector window there are some icons and a 'More actions' dropdown. Below is the list of the features in Flutter Widget Inspector.

 

Select Widget Mode Flutter - Widget Inspector - Select Widget Mode Icon

You can enable/disable select widget mode by clicking on the icon. If the select widget mode is enabled, you can click on a widget on the screen and the selected widget in the inspector will follow what is being selected on the screen. On the contrary, if you select a widget in the inspector, it will update the selected (highlighted) widget on the screen.

Flutter - Widget Inspector - Select Widget Mode

 

Refresh Widget Info Flutter - Widget Inspector - Refresh Tree Icon

The refresh widget info icon is used for refreshing the widget tree. If you add or remove a widget and use hot reload, you need to press this icon in order to update the widget tree in the inspector.

 

Performance Overlay Flutter - Widget Inspector - Performance Overlay Icon

If performance overlay is enabled, the maximum and average frame rate (ms/frame) for raster and UI will be displayed on the screen in the form of graphs.

Flutter - Widget Inspector - Performance Overlay

 

Show Debug Paint Flutter - Widget Inspector - Show Debug Paint Icon

Enabling show debug paint allows you to see how each widget is rendered. It shows the borders, padding, alignment, and spaces of the widgets displayed on the screen.

Flutter - Widget Inspector - Show Debug Paint

 

Show Paint Baselines Flutter - Widget Inspector - Paint Baselines Icon

If this is enabled, it will cause each RenderBox to paint its text baselines with a line.

Flutter - Widget Inspector - Paint Baselines

 

Slow Animations Flutter - Widget Inspector - Slow Animations Icon

It can be used to slow down animations to make inspection possible.

 

Show Repaint Rainbow Flutter - Widget Inspector - Repaint Rainbows Icon

If this is enabled, it will show rotating colors on layers when repainting.

Flutter - Widget Inspector - Show Repaint Rainbow

 

Show/Hide Debug Mode Banner Flutter - Widget Inspector - Debug Mode Icon

This allows you to show/hide debug mode banner when running a debug build.

 

That's how to use the Flutter Widget Inspector in Android Studio.