Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Autocomplete layout with the new OverlayPortal childLayoutBuilder API #165249

Merged
merged 18 commits into from
Mar 19, 2025

Conversation

LongCatIsLooong
Copy link
Contributor

@LongCatIsLooong LongCatIsLooong commented Mar 15, 2025

Fixes #160625

This also makes it very easy to implement #101620.

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@github-actions github-actions bot added the framework flutter/packages/flutter repository. See also f: labels. label Mar 15, 2025
@LongCatIsLooong LongCatIsLooong marked this pull request as ready for review March 18, 2025 01:15
@victorsanni
Copy link
Contributor

Looks really great! Especially getting rid of those extra pumps. I'm still familiarizing myself with the new OverlayPortal.overlayChildLayoutBuilder constructor, but so far this PR lgtm.

@victorsanni victorsanni requested a review from justinmc March 18, 2025 19:18
Copy link
Contributor

@justinmc justinmc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍 . This is definitely a lot simpler. Since all the tests pass I assume it solves all of the complicated cases that we tested in #143249.

I'm really glad we have something like this built-in now. When I was working on this layout, I knew that there must be Flutter app developers that are struggling with the same kind of layout problems. I wonder if MenuAnchor could also benefit from being migrated to this approach?

Do you know how this approach will be affected by soft keyboard opening and closing as in #157664? CC @victorsanni

}
final Size fieldSize = layoutInfo.childSize;
final Matrix4 invertTransform = layoutInfo.childPaintTransform.clone()..invert();
final Rect overlayRectInField = MatrixUtils.transformRect(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain to me what overlayRectInField is in relation to the field and the overlay? Just to help me follow this code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its the rect of the overlay in field view's coordinates.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh got it! I was trying everything else in my head and couldn't get the math to make sense. Thanks for adding the comment.

@@ -326,8 +326,6 @@ void main() {

// Tap on the text field to open the options.
await tester.tap(find.byKey(fieldKey));
// Two pumps required due to post frame callback.
await tester.pump();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Super excited to see the extra pumps gone.

@victorsanni
Copy link
Contributor

Do you know how this approach will be affected by soft keyboard opening and closing

Correct me if I'm wrong @LongCatIsLooong but wouldn't that just involve incorporating the keyboard insets in optionsViewMaxHeight?

// rect.
final Rect overlayRectInField = MatrixUtils.transformRect(
invertTransform,
Offset.zero & layoutInfo.overlaySize,
Copy link
Contributor Author

@LongCatIsLooong LongCatIsLooong Mar 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know how this approach will be affected by soft keyboard opening and closing

Correct me if I'm wrong @LongCatIsLooong but wouldn't that just involve incorporating the keyboard insets in optionsViewMaxHeight?

@victorsanni I think this is the rect you want to incorporate the keyboard insets into.

@LongCatIsLooong LongCatIsLooong added the autosubmit Merge PR when tree becomes green via auto submit App label Mar 18, 2025
Copy link
Contributor

auto-submit bot commented Mar 18, 2025

autosubmit label was removed for flutter/flutter/165249, because - The status or check suite Google testing has failed. Please fix the issues identified (or deflake) before re-applying this label.

@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Mar 18, 2025
@LongCatIsLooong LongCatIsLooong added the autosubmit Merge PR when tree becomes green via auto submit App label Mar 19, 2025
@auto-submit auto-submit bot added this pull request to the merge queue Mar 19, 2025
Merged via the queue into flutter:master with commit 342223f Mar 19, 2025
76 checks passed
@flutter-dashboard flutter-dashboard bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Mar 19, 2025
@LongCatIsLooong LongCatIsLooong deleted the autocomplete branch March 19, 2025 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
framework flutter/packages/flutter repository. See also f: labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RawAutocomplete options don't relayout if the field layout algorithm changes the field's width
3 participants