Why does Row give it's children infinite width instead of its remaining space?

I’m trying to understand the layout algorithm and the rationale behind it. It appears that Row gives a width constraint of infinity to its children and this causes certain issues. I wonder, why does it not give its remaining width instead? Eg, if it was constrained with 600 px, and had 3 children, it could:

  • give first a max width of 600.
  • first child uses 100
  • give the second 600-100 = 500
  • repeat for other children…

Actually, a Row always gives its unconstrained children infinite width constraints, even if the Row itself is in a bounded space. It does this so children can size themselves to their natural width.

The issue only happens when a child (like a TextField or another scrollable view) also wants infinite width. To force a child to only take up the remaining space of the Row, you have to wrap that child in an Expanded or Flexible widget!

Maybe the only answer is that it “is what it is”, but it doesn’t make sense to me. If the Row is constrained to a max width of, say, 600px, it’s not going to be able to render wider than 600px, so why not pass that “max width” down, so its children at least of a chance to try to adapt to it. That seems like the point of a max width constraint!

Well the layout algorithm is explained in the Row docs:

Also there is a lot of documentation on the constraints and sizing in general here:

But I couldn’t find the exact rationel behind it. I think its meanly because its used for flexible layout.