Skip to content

Conversation

@github-actions github-actions bot added framework flutter/packages/flutter repository. See also f: labels. f: cupertino flutter/packages/flutter/cupertino repository labels Aug 28, 2025
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request correctly addresses an issue where CupertinoNavigationBar components failed to respect ambient MediaQueryData, leading to incorrect rendering in dark mode. The fix, which involves using MediaQuery.of(context).copyWith() instead of creating a new MediaQueryData, is appropriate and well-implemented across all affected components. The new test case effectively validates this change. My review includes a suggestion to improve maintainability by refactoring duplicated code and a high-severity comment to fix a potential bug in the new test to ensure its reliability.

Copy link
Contributor

@dkwingsmt dkwingsmt left a comment

Choose a reason for hiding this comment

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

LGTM with a minor suggestion

middle: const _ExpectCustomMediaQuery(value: value, index: 0x000100),
trailing: CupertinoButton(
onPressed: () {},
child: const _ExpectCustomMediaQuery(value: value, index: 0x010000),
Copy link
Contributor

Choose a reason for hiding this comment

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

While the current way is acceptable, I'd prefer if you can explore a better style that writes the expects in the test body instead of in the class, which is hard to find.

Can you make _ExpectCustomMediaQuery accept a void callback instead and define the expects in the callback?

Copy link
Contributor

Choose a reason for hiding this comment

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

Also probably add a "regression test" comment explaining why these expectations make sense

Copy link
Contributor Author

Choose a reason for hiding this comment

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

While the current way is acceptable, I'd prefer if you can explore a better style that writes the expects in the test body instead of in the class, which is hard to find.

Ah. I implemented it that way because it was consistent with the _ExpectStyles class in the same file. But then the _ExpectStyles class is reused across multiple tests. I can explore a solution contained entirely within the test itself.

const double value = 10.0;

void expectCustomMediaQueryData(BuildContext context) {
expect(MediaQuery.platformBrightnessOf(context), Brightness.dark);
Copy link
Contributor

@dkwingsmt dkwingsmt Sep 4, 2025

Choose a reason for hiding this comment

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

This looks great, but is it ok if it doesn't check the value anymore? (Which I'm ok with since the original issue wasn't about custom values)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The problem with that is a future change might copy over only the mediaQueryData brightness leaving the other properties out. And we want to prevent against that regression. But MediaQueryData has many properties, so I'm thinking of testing with a subset of those properties numerous enough to protect against regression.

What do you think is the optimal approach here?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah I think this is sufficient. Just a few is enough to verify our approach here, and thoroughly testing copyWith should be done in MediaQueryData's tests.

@victorsanni victorsanni added the autosubmit Merge PR when tree becomes green via auto submit App label Sep 8, 2025
@auto-submit auto-submit bot added this pull request to the merge queue Sep 8, 2025
@victorsanni victorsanni removed this pull request from the merge queue due to a manual request Sep 8, 2025
@flutter-dashboard flutter-dashboard bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Sep 8, 2025
Copy link
Contributor

@MitchellGoodwin MitchellGoodwin left a comment

Choose a reason for hiding this comment

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

LGTM as well

@victorsanni victorsanni added the autosubmit Merge PR when tree becomes green via auto submit App label Sep 8, 2025
@auto-submit auto-submit bot added this pull request to the merge queue Sep 8, 2025
Merged via the queue into flutter:master with commit d328555 Sep 8, 2025
80 of 81 checks passed
@flutter-dashboard flutter-dashboard bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Sep 8, 2025
@victorsanni victorsanni deleted the nav-bar-fix branch September 9, 2025 19:31
auto-submit bot pushed a commit to flutter/packages that referenced this pull request Sep 10, 2025
flutter/flutter@973320c...a082096

2025-09-09 [email protected] Roll Packages from 24588c6 to 2d651b2 (2 revisions) (flutter/flutter#175130)
2025-09-09 [email protected] Roll Skia from ab13fd19dd32 to 19ba56dde579 (2 revisions) (flutter/flutter#175127)
2025-09-09 [email protected] Roll Skia from 29a015f8712b to ab13fd19dd32 (2 revisions) (flutter/flutter#175108)
2025-09-09 [email protected] Roll Skia from 6a4613b83365 to 29a015f8712b (5 revisions) (flutter/flutter#175106)
2025-09-09 [email protected] Roll Dart SDK from 7b645442db0f to f446144fb7c9 (2 revisions) (flutter/flutter#175104)
2025-09-08 [email protected] Nav bar static components respect ambient MediaQueryData (flutter/flutter#174673)
2025-09-08 [email protected] fix typo in test documentation #2 (flutter/flutter#174707)
2025-09-08 [email protected] Update ImageReaderSurfaceProducer.MAX_IMAGES to include the maximum number of retained dequeued images (flutter/flutter#174971)
2025-09-08 49699333+dependabot[bot]@users.noreply.github.com Bump actions/labeler from 5.0.0 to 6.0.1 in the all-github-actions group (flutter/flutter#175093)
2025-09-08 [email protected] Roll Skia from 25f00cb247f2 to 6a4613b83365 (3 revisions) (flutter/flutter#175087)
2025-09-08 [email protected] Roll Dart SDK from 83c6b6124380 to 7b645442db0f (1 revision) (flutter/flutter#175086)
2025-09-08 [email protected] Impeller: Convert GLProc name field and GLErrorToString to std::string_view (flutter/flutter#173771)
2025-09-08 [email protected] Depend on operator overload synthesis for three-way and equality comparisons. (flutter/flutter#174892)
2025-09-08 [email protected] Define a concept for UniqueObjectTraits. (flutter/flutter#174905)
2025-09-08 [email protected] Roll Skia from 0c2b0a00b7b5 to 25f00cb247f2 (1 revision) (flutter/flutter#175077)
2025-09-08 [email protected] Fix GitHub labeler platform-android typo (flutter/flutter#175076)
2025-09-08 [email protected] [Gradle 9] Removed `minSdkVersion` and only use `minSdk` (flutter/flutter#173892)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC [email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
mboetger pushed a commit to mboetger/flutter that referenced this pull request Sep 18, 2025
)

Fixes [CupertinoSlidingSegmentedControl in CupertinoNavigationBar
renders incorrectly in dark brightness (starting
3.35.0)](flutter#174642)
Fixes [[Cupertino] MediaQuery.of(context) returns Size(0,0) inside
CupertinoNavigationBar trailing since Flutter
3.35](flutter#174771 (comment))

Bug was introduced in [CupertinoSliverNavigationBar respects
accessibility text
scaling](flutter#168866)

See
flutter#174642 (comment)
Jaineel-Mamtora pushed a commit to Jaineel-Mamtora/flutter_forked that referenced this pull request Sep 24, 2025
)

Fixes [CupertinoSlidingSegmentedControl in CupertinoNavigationBar
renders incorrectly in dark brightness (starting
3.35.0)](flutter#174642)
Fixes [[Cupertino] MediaQuery.of(context) returns Size(0,0) inside
CupertinoNavigationBar trailing since Flutter
3.35](flutter#174771 (comment))

Bug was introduced in [CupertinoSliverNavigationBar respects
accessibility text
scaling](flutter#168866)

See
flutter#174642 (comment)
lukemmtt added a commit to TimeFinderApp/pull_down_button that referenced this pull request Oct 9, 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)
danferreira pushed a commit to danferreira/packages that referenced this pull request Oct 22, 2025
…r#9983)

flutter/flutter@973320c...a082096

2025-09-09 [email protected] Roll Packages from 24588c6 to 2d651b2 (2 revisions) (flutter/flutter#175130)
2025-09-09 [email protected] Roll Skia from ab13fd19dd32 to 19ba56dde579 (2 revisions) (flutter/flutter#175127)
2025-09-09 [email protected] Roll Skia from 29a015f8712b to ab13fd19dd32 (2 revisions) (flutter/flutter#175108)
2025-09-09 [email protected] Roll Skia from 6a4613b83365 to 29a015f8712b (5 revisions) (flutter/flutter#175106)
2025-09-09 [email protected] Roll Dart SDK from 7b645442db0f to f446144fb7c9 (2 revisions) (flutter/flutter#175104)
2025-09-08 [email protected] Nav bar static components respect ambient MediaQueryData (flutter/flutter#174673)
2025-09-08 [email protected] fix typo in test documentation flutter#2 (flutter/flutter#174707)
2025-09-08 [email protected] Update ImageReaderSurfaceProducer.MAX_IMAGES to include the maximum number of retained dequeued images (flutter/flutter#174971)
2025-09-08 49699333+dependabot[bot]@users.noreply.github.com Bump actions/labeler from 5.0.0 to 6.0.1 in the all-github-actions group (flutter/flutter#175093)
2025-09-08 [email protected] Roll Skia from 25f00cb247f2 to 6a4613b83365 (3 revisions) (flutter/flutter#175087)
2025-09-08 [email protected] Roll Dart SDK from 83c6b6124380 to 7b645442db0f (1 revision) (flutter/flutter#175086)
2025-09-08 [email protected] Impeller: Convert GLProc name field and GLErrorToString to std::string_view (flutter/flutter#173771)
2025-09-08 [email protected] Depend on operator overload synthesis for three-way and equality comparisons. (flutter/flutter#174892)
2025-09-08 [email protected] Define a concept for UniqueObjectTraits. (flutter/flutter#174905)
2025-09-08 [email protected] Roll Skia from 0c2b0a00b7b5 to 25f00cb247f2 (1 revision) (flutter/flutter#175077)
2025-09-08 [email protected] Fix GitHub labeler platform-android typo (flutter/flutter#175076)
2025-09-08 [email protected] [Gradle 9] Removed `minSdkVersion` and only use `minSdk` (flutter/flutter#173892)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC [email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
lukemmtt added a commit to TimeFinderApp/pull_down_button that referenced this pull request Nov 1, 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)
lucaantonelli pushed a commit to lucaantonelli/flutter that referenced this pull request Nov 21, 2025
)

Fixes [CupertinoSlidingSegmentedControl in CupertinoNavigationBar
renders incorrectly in dark brightness (starting
3.35.0)](flutter#174642)
Fixes [[Cupertino] MediaQuery.of(context) returns Size(0,0) inside
CupertinoNavigationBar trailing since Flutter
3.35](flutter#174771 (comment))

Bug was introduced in [CupertinoSliverNavigationBar respects
accessibility text
scaling](flutter#168866)

See
flutter#174642 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

f: cupertino flutter/packages/flutter/cupertino repository framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

3 participants