8000 Fix: Update anchorRect for overlayBuilder when anchor moves by rkishan516 · Pull Request #169814 · flutter/flutter · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix: Update anchorRect for overlayBuilder when anchor moves #169814

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rkishan516
Copy link
Contributor

Fix: Update anchorRect for overlayBuilder when anchor moves
fixes: #169457

Pre-launch Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement].
  • I signed the [CLA].
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is [test-exempt].
  • I followed the [breaking change policy] and added [Data Driven Fixes] where supported.
  • All existing and new tests are passing.

@github-actions github-actions bot added the framework flutter/packages/flutter repository. See also f: labels. label May 31, 2025
@rkishan516
Copy link
Contributor Author
 SchedulerBinding.instance.addPostFrameCallback((Duration timestamp) {
      if (!mounted || !_overlayController.isShowing) {
        return;
      }
      if (info != _getRawMenuOverlayInfo(context)) {
        // Rebuild overlayBuilder
        _overlayController.hide();
        _overlayController.show();
      }
    });

Somehow being callback inside build method, I am not feeling good + the way I am rebuilding overlay. I would love to hear feedback, how we can achieve this otherwise.

@rkishan516 rkishan516 force-pushed the raw-menu-achor-info branch from 3155855 to a681e98 Compare May 31, 2025 14:50

Widget _buildOverlay(BuildContext context) {
final RawMenuOverlayInfo info = _getRawMenuOverlayInfo(context);
SchedulerBinding.instance.addPostFrameCallback((Duration timestamp) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this always need to be in a postframe callback?

Copy link
Contributor Author
@rkishan516 rkishan516 Jun 19, 2025

Choose a reason for hiding this comment

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

Yes because otherwise we always use older anchorRect.
Also if overlay is opened in first frame, it will open at (0,0).

Because logically first anchor should settle down its position then overlayBuilder should lay itself.

@dkwingsmt dkwingsmt self-requested a review June 18, 2025 18:50
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.

MenuAnchor does not update menuChildren position after being repositioned.
2 participants
0