Search code examples
fluttertestingintegration-testing

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). It should also be interesting in the CI pipeline. 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


Solution

  • I was able to fix this by using the window_size package (see this answer). Note that this package is not yet on pub.dev and maybe this feature will be integrated in the flutter framework. Once setup you can just use:

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