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;
}