简体   繁体   English

Flutter 集成测试中的桌面窗口大小

[英]Desktop window size in flutter integration testing

Now that the Desktop embedding in flutter is almost stable it is interesting to perform the integration testing directly on the OS you are using during the development (instead of initialize every time an emulator and wait until is ready).既然 Desktop 嵌入 Flutter 几乎稳定,那么在开发过程中直接在您使用的操作系统上执行集成测试很有趣(而不是每次模拟器都初始化并等到准备就绪)。 It should also be interesting in the CI pipeline.它在 CI 管道中也应该很有趣。 Unfortunatly I can't find a way to set the window size dimension when I perform the test.不幸的是,我在执行测试时找不到设置窗口大小尺寸的方法。 This is needed for adaptive apps.这是自适应应用程序所必需的。

I tried with:我试过:

tester.binding.window.physicalSizeTestValue = const Size(300, 300);

but it didn't worked for me但它对我不起作用

Try setSurfaceSize :尝试setSurfaceSize

  tester.binding.setSurfaceSize(const Size(300, 300));

This works for me.这对我有用。

I was able to fix this by using the window_size package ( see this answer ).我能够通过使用window_size包来解决这个问题(参见这个答案)。 Note that this package is not yet on pub.dev and maybe this feature will be integrated in the flutter framework.请注意,这个包还没有在 pub.dev 上,也许这个特性会被集成到 flutter 框架中。 Once setup you can just use:一旦设置你就可以使用:

setWindowMinSize(const Size(300, 300));
setWindowMaxSize(const Size(300, 300));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM