0
votes

Let's say I have a stack of 100 positioned widget children, I add one new positioned widget to that stack but the rest don't change, then I setState to rebuild that stack, should all 100 children run their rebuild function? I ask because this is happening in my app but was hoping I could prevent the rebuild of the entire stack, since flutter should see most of the stack as unchanged.

edit: [more accurately, how do i make sure i'm not re-rendering all 100 widgets in the stack when i add one child or remove one child, is there a way to verify, inspect the render tree]

1
yes, all of them should rebuildpskink
is there a way to isolate the 100 by wrapping them somehow, or other solutionAaron Halvorsen
btw what are those 100 widgets? are they typical widgets like buttons, text fields, sliders etc or you are trying to use some widgets in a hacky way?pskink
they're draggable widgets that can be moved around the screen that have a variety of widget trees with text , images, CustomPainter paths.Aaron Halvorsen
they have positions so they can stay in that position after dragging. as you can imagine i don't want all of them to refresh if i just add one or remove one.Aaron Halvorsen

1 Answers

1
votes

All the widgets inside a stateful widget should be rebuild in every setState, To prevent of setState some widgets you should have a separate stateful widget for the stack. this may useful