Skip to content

fix: measure shrink children via dry layout (#85)#98

Merged
andyhorn merged 3 commits into
mainfrom
shrink-measure-children
May 19, 2026
Merged

fix: measure shrink children via dry layout (#85)#98
andyhorn merged 3 commits into
mainfrom
shrink-measure-children

Conversation

@andyhorn
Copy link
Copy Markdown
Owner

Summary

  • Replace getMinIntrinsicHeight/Width(infinity) with child.getDryLayout(...) for ResizableSize.shrink() measurement
  • Use tight cross-axis + loose-bounded main-axis constraints (cap = parent max − pixels − dividers) so descendant Expanded widgets work and SingleChildScrollView reports its actual content size
  • Cache shrink sizes from the measurement pass so _getChildConstraints does not re-measure

Fixes #85.

Background

SingleChildScrollView reports 0 for intrinsic main-axis dimension on its scroll axis. The previous code called getMinIntrinsicHeight(double.infinity) for shrink sizing, so any shrink child wrapping a scroll view collapsed to zero. Intrinsics also passed double.infinity on the cross-axis, which is incorrect — the cross-axis is tight from the parent.

Test plan

  • flutter test — 80/80 pass (79 existing + 1 new)
  • New regression test: vertical resizable with ResizableSize.shrink() wrapping SingleChildScrollView(child: SizedBox(height: 150)) reports 150

Known limitation

Nested ResizableContainer as a shrink child still returns 0, since ResizableLayoutRenderObject does not override computeDryLayout. Worth a follow-up.

🤖 Generated with Claude Code

andyhorn and others added 2 commits May 18, 2026 20:54
Replaces intrinsic-based shrink measurement with a dry layout pass using
tight cross-axis and loose-bounded main-axis constraints. Intrinsic
dimensions are 0 for SingleChildScrollView on its scroll axis, which
caused shrink children to collapse when wrapping a scroll view.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Demonstrates ResizableSize.shrink() wrapping a SingleChildScrollView with
variable-height content — the case from issue #85.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@andyhorn andyhorn merged commit c6fc50e into main May 19, 2026
1 check passed
@andyhorn andyhorn deleted the shrink-measure-children branch May 19, 2026 04:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

.shrink() does not catch childrens size.

1 participant