Visitar URL original
Fix: menu positioning in CupertinoNavigationBar on Flutter 3.35.x by lukemmtt · Pull Request #76 · notDmDrl/pull_down_button · GitHub
Skip to content
This repository was archived by the owner on May 20, 2026. It is now read-only.

Fix: menu positioning in CupertinoNavigationBar on Flutter 3.35.x - #76

Closed
lukemmtt wants to merge 1 commit into
notDmDrl:mainfrom
TimeFinderApp:cupertino-navigator-workaround
Closed

lukemmtt wants to merge 1 commit into
notDmDrl:mainfrom
TimeFinderApp:cupertino-navigator-workaround

Conversation

@lukemmtt

@lukemmtt lukemmtt commented Oct 9, 2025 •

Copy link
Copy Markdown

Summary

Fixes menu positioning and animation issues when PullDownButton is used in CupertinoNavigationBar's trailing widget on Flutter 3.35.0+.

Fixes #74

Videos

Before
before.mp4
After
after.mp4

Root Cause

Flutter 3.35.0 introduced a regression (via PR flutter/flutter#168866) where CupertinoNavigationBar wraps its children (leading, middle, trailing) with a new MediaQueryData that only sets the textScaler field:

// Broken in Flutter 3.35.0
MediaQuery(
  data: MediaQueryData(textScaler: ...),  // All other fields default!
  child: userTrailing,
)

This causes all other MediaQueryData fields to reset to defaults:

  • size → Size(0, 0)
  • padding → EdgeInsets.zero
  • devicePixelRatio → 1.0

PullDownButton's positioning logic relies on MediaQuery.of(context).size to calculate screen bounds, which now returns invalid dimensions when the button is inside CupertinoNavigationBar's trailing widget.

Solution

Pass the navigator overlay's context for MediaQuery lookups instead of using the button's context. The overlay always has complete MediaQueryData with correct screen dimensions.

Changes:

  • Add optional mediaQueryContext parameter to getRect() in extensions.dart
  • Add optional overlayContext parameter to animationAlignment() in route.dart
  • Update both call sites in pull_down_button.dart to pass navigator.overlay!.context

@notDmDrl

Copy link
Copy Markdown
Owner

Hi @lukemmtt

Thank you very much for the fix! LGTM 👍

I've just pushed the preview 1.0.0 version. Could you update your PR to fix all the conflicts? Thx 😄

@notDmDrl
notDmDrl self-requested a review October 27, 2025 23:17
@notDmDrl notDmDrl added bug Something isn't working flutter-specific This issue is Flutter specific, no fixes are possible in this repo labels Oct 27, 2025
Fixes menu positioning and animation issues when PullDownButton is used in CupertinoNavigationBar's trailing widget on Flutter 3.35.0+.

Root cause: Flutter 3.35.0 introduced a regression where CupertinoNavigationBar wraps children with incomplete MediaQueryData (only textScaler set, causing size to default to Size(0,0)).

Solution: Pass overlay context for MediaQuery lookups instead of using the button's context. The overlay always has complete MediaQueryData.

Changes:
- Add mediaQueryContext parameter to getRect()
- Add overlayContext parameter to animationAlignment()
- Pass navigator.overlay.context for both MediaQuery lookups

This fix is forward-compatible and will continue working when Flutter's fix lands in stable.

Related:
- flutter/flutter#174771 (MediaQuery returns Size(0,0) in nav bar)
- flutter/flutter#174673 (Flutter's fix, not yet in stable)
- notDmDrl#74 (Original bug report)
@lukemmtt
lukemmtt force-pushed the cupertino-navigator-workaround branch from d7c9ffb to 8c5ee8d Compare November 1, 2025 18:18
@lukemmtt lukemmtt closed this Mar 8, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

bug Something isn't working flutter-specific This issue is Flutter specific, no fixes are possible in this repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[MAJOR BUG] Menu positioning issue after updating to Flutter 3.35.0

2 participants