mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
The initial fix was updating Image to NetworkImage, which is the new name for the Widget that takes a URL to an image. However, this exposed an underlying bug: slots given to MultiChildRenderObjectWrapper children were not getting updated in the initial build. Initially, we don't have a next sibling for any of the children's roots, since we haven't yet synced anyone after the one we're syncing. So we pass null. However, as soon as we build the next one, the previous one now has an out of date slot: null means "append", but it needs to be "insert before the newly inserted root of the next child". So now we update the slot after each insertion. This returned the spinning_mixed demo to its original state, but that state was buggy: the image would expand to fit the button and push the text out of the button. To resolve that, this patch changes how RenderImage sizes an image that has no desired dimensions but has some constraints that make it impossible to show the image at full size: now, we try to maintain the aspect ratio and honour the constraints all at the same time. Also, if the constraints are tight we skip all that logic, because it'd be a waste of time. To help with the slot issue above, I needed to see the widget tree and the render tree and compare them (to see where the nodes were getting out of order), so I also extended Widget.toString() to dump a deep tree of the widget hierarchy. Also, while debugging all this I noticed we sometimes walk the tree into nodes that are null, which causes crashes. So to avoid that I added null-checks to certain walkChildren() functions. R=abarth@chromium.org Review URL: https://codereview.chromium.org/1212943007.