在build方法中,
测试小部件包含在
MediaQuery.of(context).orientation
等于Orientation.landscape
。如何将其更改为portrait
。测试小部件包含在
MaterialApp
下。MediaQuery.of(context).orientation
等于Orientation.landscape
。如何将其更改为portrait
。MaterialApp
下。将查询方向的小部件包装在中
MediaQuery(
data: MediaQueryData
.fromWindow(ui.window)
.copyWith(size: const Size(600.0, 800.0)),
child: widgetToTest,
)
对我来说起作用了。
MediaQuery.orientation
只是检查哪个尺寸更大。
Orientation get orientation {
return size.width > size.height ? Orientation.landscape : Orientation.portrait;
}