Repository navigation
The OrientationBuilder value and the MediaQuery's orientation value differ ? #177435
Description
Steps to reproduce
Hello! We deeply appreciate your ongoing development, contributions, and above all, maintenance of the excellent Flutter software.
We are using Flutter and find most aspects to be very comfortable and outstanding.
Recently, while implementing an application, we encountered the following case. We apologize for the inconvenience during your busy schedule, but we would be grateful if you could review this issue.
- Prepare a foldable Android device. (Here, we prepared an emulator for the Pixel 9 Pro Fold 36.1)
- When using OrientationBuilder with the foldable device unfolded, the results returned by MediaQuery will be inconsistent.
Expected results
We understand that OrientationBuilder depends on the orientation from the parent widget tree, but this creates inconsistencies with MediaQuery. We need to discuss either renaming the “OrientationBuilder” property in one of these mechanisms or building an entirely separate OrientationBuilder using MediaQuery values.
Actual results
Using OrientationBuilder with a folded device results in inconsistent MediaQuery outputs. While the results may be correct, I feel it would be better to either rename it or provide a dedicated widget like DeviceOrientationBuilder.
Code sample
OrientationBuilder
import 'package:flutter/material.dart';
class Orientation0 extends StatelessWidget {
const Orientation0({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Flutter OrientationBuilder'),
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
),
body: OrientationBuilder(
builder: (context, orientation) {
return Center(
child: Text(
orientation == Orientation.portrait ? 'portrait' : 'landscape',
style: Theme.of(context).textTheme.headlineLarge,
),
);
},
),
);
}
}
MediaQuery.of(context).orientation
import 'package:flutter/material.dart';
class Orientation1 extends StatelessWidget {
const Orientation1({super.key});
@override
Widget build(BuildContext context) {
final orientation = MediaQuery.of(context).orientation;
return Scaffold(
appBar: AppBar(
title: const Text('Flutter MediaQuery orientation'),
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
),
body: Center(
child: Text(
orientation == Orientation.portrait ? 'portrait' : 'landscape',
style: Theme.of(context).textTheme.headlineLarge,
),
),
);
}
}
Screenshots or Video
Screenshots / Video demonstration (Open)
| OrientationBuilder | MediaQuery.of(context).orientation |
|---|---|
![]() |
![]() |
Screenshots / Video demonstration (Fold)
| OrientationBuilder | MediaQuery.of(context).orientation |
|---|---|
![]() |
![]() |
Logs
Logs
Syncing files to device sdk gphone64 arm64... 52ms
Flutter run key commands.
r Hot reload. 🔥🔥🔥
R Hot restart.
h List all available interactive commands.
d Detach (terminate "flutter run" but leave application running).
c Clear the screen
q Quit (terminate the application on the device).
A Dart VM Service on sdk gphone64 arm64 is available at: http://127.0.0.1:50638/KafzT7NIg7E=/
The Flutter DevTools debugger and profiler on sdk gphone64 arm64 is available at: http://127.0.0.1:9103?uri=http://127.0.0.1:50638/KafzT7NIg7E=/
I/Choreographer( 9098): Skipped 52 frames! The application may be doing too much work on its main thread.
I/WindowExtensionsImpl( 9098): Initializing Window Extensions, vendor API level=9, activity embedding enabled=true
D/VRI[MainActivity]( 9098): WindowInsets changed: 2076x2152 statusBars:[0,136,0,0] navigationBars:[0,0,0,78] mandatorySystemGestures:[0,165,0,78]
D/WindowOnBackDispatcher( 9098): setTopOnBackInvokedCallback (unwrapped): android.view.ViewRootImpl$$ExternalSyntheticLambda12@8003047
I/rientation_demo( 9098): Compiler allocated 5274KB to compile void android.view.ViewRootImpl.performTraversals()
D/WindowLayoutComponentImpl( 9098): Register WindowLayoutInfoListener on Context=com.example.flutte_orientation_demo.MainActivity@4b46074, of which baseContext=android.app.ContextImpl@208595e
D/InsetsController( 9098): hide(ime())
I/ImeTracker( 9098): com.example.flutte_orientation_demo:a9cdc42e: onCancelled at PHASE_CLIENT_ALREADY_HIDDEN
W/WindowOnBackDispatcher( 9098): OnBackInvokedCallback is not enabled for the application.
W/WindowOnBackDispatcher( 9098): Set 'android:enableOnBackInvokedCallback="true"' in the application manifest.
D/ProfileInstaller( 9098): Installing profile for com.example.flutte_orientation_demo
W/WindowOnBackDispatcher( 9098): OnBackInvokedCallback is not enabled for the application.
W/WindowOnBackDispatcher( 9098): Set 'android:enableOnBackInvokedCallback="true"' in the application manifest.
W/WindowOnBackDispatcher( 9098): OnBackInvokedCallback is not enabled for the application.
W/WindowOnBackDispatcher( 9098): Set 'android:enableOnBackInvokedCallback="true"' in the application manifest.
D/ActivityThread( 9098): Package [com.android.vending] reported as REPLACED, but missing application info. Assuming REMOVED.
D/ActivityThread( 9098): Package [com.android.vending] reported as REPLACED, but missing application info. Assuming REMOVED.
W/rientation_demo( 9098): userfaultfd: MOVE ioctl seems unsupported: Connection timed out
W/WindowOnBackDispatcher( 9098): OnBackInvokedCallback is not enabled for the application.
W/WindowOnBackDispatcher( 9098): Set 'android:enableOnBackInvokedCallback="true"' in the application manifest.
D/VRI[MainActivity]( 9098): visibilityChanged oldVisibility=true newVisibility=false
D/VRI[MainActivity]( 9098): WindowInsets changed: statusBars:[0,152,0,0] navigationBars:null
D/ViewRootImpl( 9098): Skipping stats log for color mode
D/VRI[MainActivity]( 9098): WindowInsets changed: 1080x2424 navigationBars:[0,0,0,59] mandatorySystemGestures:[0,181,0,78]
D/InsetsController( 9098): hide(ime())
I/ImeTracker( 9098): com.example.flutte_orientation_demo:61dba0fa: onCancelled at PHASE_CLIENT_ALREADY_HIDDEN
W/WindowOnBackDispatcher( 9098): OnBackInvokedCallback is not enabled for the application.
W/WindowOnBackDispatcher( 9098): Set 'android:enableOnBackInvokedCallback="true"' in the application manifest.
W/WindowOnBackDispatcher( 9098): OnBackInvokedCallback is not enabled for the application.
W/WindowOnBackDispatcher( 9098): Set 'android:enableOnBackInvokedCallback="true"' in the application manifest.
D/ActivityThread( 9098): Package [com.google.android.webview] reported as REPLACED, but missing application info. Assuming REMOVED.
D/ActivityThread( 9098): Package [com.google.android.webview] reported as REPLACED, but missing application info. Assuming REMOVED.
D/ActivityThread( 9098): Package [com.google.android.as.oss] reported as REPLACED, but missing application info. Assuming REMOVED.
D/ActivityThread( 9098): Package [com.google.android.as.oss] reported as REPLACED, but missing application info. Assuming REMOVED.
D/ActivityThread( 9098): Package [com.google.android.apps.maps] reported as REPLACED, but missing application info. Assuming REMOVED.
D/ActivityThread( 9098): Package [com.google.android.apps.maps] reported as REPLACED, but missing application info. Assuming REMOVED.
D/ActivityThread( 9098): Package [com.google.android.apps.wellbeing] reported as REPLACED, but missing application info. Assuming REMOVED.
D/ActivityThread( 9098): Package [com.google.android.apps.wellbeing] reported as REPLACED, but missing application info. Assuming REMOVED.
D/ActivityThread( 9098): Package [com.google.android.apps.youtube.music] reported as REPLACED, but missing application info. Assuming REMOVED.
D/ActivityThread( 9098): Package [com.google.android.apps.youtube.music] reported as REPLACED, but missing application info. Assuming REMOVED.
D/ActivityThread( 9098): Package [com.google.android.apps.messaging] reported as REPLACED, but missing application info. Assuming REMOVED.
D/ActivityThread( 9098): Package [com.google.android.apps.messaging] reported as REPLACED, but missing application info. Assuming REMOVED.
D/ActivityThread( 9098): Package [com.google.android.googlequicksearchbox] reported as REPLACED, but missing application info. Assuming REMOVED.
D/ActivityThread( 9098): Package [com.google.android.googlequicksearchbox] reported as REPLACED, but missing application info. Assuming REMOVED.
D/ActivityThread( 9098): Package [com.google.android.contacts] reported as REPLACED, but missing application info. Assuming REMOVED.
D/ActivityThread( 9098): Package [com.google.android.contacts] reported as REPLACED, but missing application info. Assuming REMOVED.
D/ActivityThread( 9098): Package [com.google.android.apps.restore] reported as REPLACED, but missing application info. Assuming REMOVED.
D/ActivityThread( 9098): Package [com.google.android.apps.restore] reported as REPLACED, but missing application info. Assuming REMOVED.
D/ActivityThread( 9098): Package [com.google.android.partnersetup] reported as REPLACED, but missing application info. Assuming REMOVED.
D/ActivityThread( 9098): Package [com.google.android.partnersetup] reported as REPLACED, but missing application info. Assuming REMOVED.
D/ActivityThread( 9098): Package [com.google.android.tts] reported as REPLACED, but missing application info. Assuming REMOVED.
D/ActivityThread( 9098): Package [com.google.android.tts] reported as REPLACED, but missing application info. Assuming REMOVED.
D/ActivityThread( 9098): Package [com.google.android.deskclock] reported as REPLACED, but missing application info. Assuming REMOVED.
D/ActivityThread( 9098): Package [com.google.android.deskclock] reported as REPLACED, but missing application info. Assuming REMOVED.
D/ActivityThread( 9098): Package [com.google.android.apps.photos] reported as REPLACED, but missing application info. Assuming REMOVED.
D/ActivityThread( 9098): Package [com.google.android.apps.photos] reported as REPLACED, but missing application info. Assuming REMOVED.
D/ActivityThread( 9098): Package [com.google.android.accessibility.switchaccess] reported as REPLACED, but missing application info. Assuming REMOVED.
D/ActivityThread( 9098): Package [com.google.android.accessibility.switchaccess] reported as REPLACED, but missing application info. Assuming REMOVED.
D/ActivityThread( 9098): Package [com.google.android.apps.accessibility.voiceaccess] reported as REPLACED, but missing application info. Assuming REMOVED.
D/ActivityThread( 9098): Package [com.google.android.apps.accessibility.voiceaccess] reported as REPLACED, but missing application info. Assuming REMOVED.
D/ActivityThread( 9098): Package [com.google.android.dialer] reported as REPLACED, but missing application info. Assuming REMOVED.
D/ActivityThread( 9098): Package [com.google.android.dialer] reported as REPLACED, but missing application info. Assuming REMOVED.
D/ActivityThread( 9098): Package [com.google.android.apps.safetyhub] reported as REPLACED, but missing application info. Assuming REMOVED.
D/ActivityThread( 9098): Package [com.google.android.apps.safetyhub] reported as REPLACED, but missing application info. Assuming REMOVED.
D/ActivityThread( 9098): Package [com.google.android.inputmethod.latin] reported as REPLACED, but missing application info. Assuming REMOVED.
D/ActivityThread( 9098): Package [com.google.android.inputmethod.latin] reported as REPLACED, but missing application info. Assuming REMOVED.
D/ActivityThread( 9098): Package [com.google.android.youtube] reported as REPLACED, but missing application info. Assuming REMOVED.
D/ActivityThread( 9098): Package [com.google.android.youtube] reported as REPLACED, but missing application info. Assuming REMOVED.
Flutter Doctor output
Doctor output
❯ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.32.8, on macOS 15.7 24G222 darwin-arm64, locale ja-JP)
[✓] Android toolchain - develop for Android devices (Android SDK version 36.1.0)
[✓] Xcode - develop for iOS and macOS (Xcode 16.4)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2025.1)
[✓] VS Code (version 1.105.1)
[✓] Connected device (4 available)
[✓] Network resources
• No issues found!



Activity
[-]The OrientationBuilder value and the MediaQuery's orientation value differ.[/-][+]The OrientationBuilder value and the MediaQuery's orientation value differ[/+][-]The OrientationBuilder value and the MediaQuery's orientation value differ[/-][+]The OrientationBuilder value and the MediaQuery's orientation value differ ?[/+]Add DeviceOrientationBuilder widget
huycozy commentedon Oct 24, 2025
Thanks for the report. I'm also able to reproduce the issue on the latest Flutter stable and main channels. Tested on Pixel 9 Pro Fold (emulator).
Flutter versions (stable and main)
I combined your 2 snippet codes into one example here:
Sample code
Demo
untitled.webm
KikuchiTomo commentedon Oct 27, 2025
Thank you for responding!
I understand you're likely focused on addressing other more critical issues, so I'm happy to wait for a discussion on this matter.
If you could just indicate what kind of fix is needed, I can create the PR myself.
(Actually, I've already created and submitted a PR ( #177437 ), but since it might not align with your team's approach, I'd appreciate discussing it here.)
KikuchiTomo commentedon Nov 4, 2025
Hello, I'd be grateful if you could reply, even briefly. That's because if you could let me know which approach to take, I can make the necessary changes to the PR below anytime!
#177437
victorsanni commentedon Nov 4, 2025
Hi @KikuchiTomo, I left some comments on the PR, could you address them to continue the review iteration? So far the approach to add a new widget lgtm.
KikuchiTomo commentedon Nov 4, 2025
Thanks for your reply!
I've changed it to a single file.
I'd appreciate it if you could take a look whenever you have a moment.
Add DeviceOrientationBuilder widget by MediaQuery orientation (#177437)
Add DeviceOrientationBuilder widget by MediaQuery orientation (flutte…
github-actions commentedon Nov 24, 2025
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.Add DeviceOrientationBuilder widget by MediaQuery orientation (flutte…
Add DeviceOrientationBuilder widget by MediaQuery orientation (flutte…
Add DeviceOrientationBuilder widget by MediaQuery orientation (#177437)