use*_*276 5 ui-testing flutter
在构建方法中,MediaQuery.of(context).orientation
等于Orientation.landscape
. 如何使其成为portrait
.
测试小部件被包裹在MaterialApp
.
包装查询方向的小部件
MediaQuery(
data: MediaQueryData
.fromWindow(ui.window)
.copyWith(size: const Size(600.0, 800.0)),
child: widgetToTest,
)
Run Code Online (Sandbox Code Playgroud)
为我工作。
MediaQuery.orientation
只是检查哪个维度更大
Orientation get orientation {
return size.width > size.height ? Orientation.landscape : Orientation.portrait;
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1784 次 |
最近记录: |