[material_ui] SearchAnchor overlay expands to full screen when viewport size changes - #12466
[material_ui] SearchAnchor overlay expands to full screen when viewport size changes#12466elliette wants to merge 7 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request wraps the SearchAnchor view content in a LayoutBuilder to dynamically adjust its constraints based on the parent container, enabling the full-screen view to resize on viewport changes such as device rotation. The review feedback suggests setting minWidth and minHeight to 0.0 when showFullScreenView is true to prevent potential overflow issues when parent constraints are smaller than the minimum dimensions.
| constraints: BoxConstraints( | ||
| minWidth: minWidth, | ||
| maxWidth: widget.showFullScreenView | ||
| ? math.max(constraints.maxWidth, minWidth) | ||
| : _viewRect.width, | ||
| minHeight: minHeight, | ||
| maxHeight: widget.showFullScreenView | ||
| ? math.max(constraints.maxHeight, minHeight) | ||
| : _viewRect.height, | ||
| ), |
There was a problem hiding this comment.
When widget.showFullScreenView is true, the search view is intended to be full screen. If the parent constraints are smaller than minWidth or minHeight (e.g., on very small screens or inside a small nested Navigator), forcing the constraints to minWidth/minHeight via math.max will cause the full-screen view to overflow its parent boundaries.
Instead of forcing the maximum constraints to be at least minWidth/minHeight, we can set the minWidth/minHeight to 0.0 when widget.showFullScreenView is true. This allows the full-screen view to scale down and fit perfectly within the parent constraints without overflowing or throwing assertion errors.
constraints: BoxConstraints(
minWidth: widget.showFullScreenView ? 0.0 : minWidth,
maxWidth: widget.showFullScreenView
? constraints.maxWidth
: _viewRect.width,
minHeight: widget.showFullScreenView ? 0.0 : minHeight,
maxHeight: widget.showFullScreenView
? constraints.maxHeight
: _viewRect.height,
),
Port over flutter/flutter#186537 from flutter/flutter.
Fixes flutter/flutter#186154
Pre-Review Checklist
[shared_preferences]///).If you need help, consider asking for advice on the #hackers-new channel on Discord.
Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the
gemini-code-assistbot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.Footnotes
Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. ↩ ↩2