3
votes

I've got a parent widget that has a Stack with two children. When using setState in the parent, without actually changing something (setState with empty body) why are the build methods of the children being called?

Is it not the case that flutter rebuilds only the widgets with dirty params?

1

1 Answers

3
votes

Flutter will run the build function for all children (exception being const Widgets). It will not rerender them though. If Flutter finds that nothing changed in the widget, it will just reuse the previous render.

The program has no way of knowing if state has changed, unless it checks by running build.