Skip to content

Conversation

@lukemmtt
Copy link

@lukemmtt lukemmtt commented Oct 9, 2025

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:

  • sizeSize(0, 0)
  • paddingEdgeInsets.zero
  • devicePixelRatio1.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
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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