In build method, MediaQuery.of(context).orientation
equals Orientation.landscape
. How to make it into portrait
.
The test widget is wrap under MaterialApp
.
In build method, MediaQuery.of(context).orientation
equals Orientation.landscape
. How to make it into portrait
.
The test widget is wrap under MaterialApp
.
Wrapping the widgets that query orientation in
MediaQuery(
data: MediaQueryData
.fromWindow(ui.window)
.copyWith(size: const Size(600.0, 800.0)),
child: widgetToTest,
)
worked for me.
MediaQuery.orientation
just checks what dimension is bigger
Orientation get orientation {
return size.width > size.height ? Orientation.landscape : Orientation.portrait;
}
By default app is in portrait mode
To set landscape orientation in your test you have to update you device physical size from the test.
double landscapeHeight = any landscape height;
double landscapeWidth = any landscape width;
tester.view.physicalSize = Size(landscapeWidth, landscapeHeight);
After this your testing screen size would be the above one if you want to test in portrait mode then you have to reset this.
tester.view.resetPhysicalSize();
© 2022 - 2024 — McMap. All rights reserved.