Code source
Is there any trick to know that a widget has been rebuilt?
As a demonstration, i.e. if we randomly colored the widgets on every rebuild, it would look like this:
Flutter actually has built-in functionality for exactly what you are trying to achieve in the DevTools inspector:
This is called the Repaint Rainbow and it can be enabled in Android Studio, i.e. IntelliJ, as demonstrated above or directly in Dart DevTools:
Shows rotating colors on layers when repainting.
From the linked article
There can be many reasons for repaints and seeing a widget rebuild does not inherently mean that you triggered the rebuild as it can also come from somewhere else in the tree.
You cannot know if a widget has been rebuilt in code because that is against how the framework works - you can obviously catch any build or paint calls by integrating that into your build
or paint
function, but you should really not do that because builds and paints should be idempotent.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With