I am building a flutter desktop app for MacOS & Windows. I am using the windows_manager package. I am not able to resize or maximize my app on Windows whereas on MacOS the same code is working as expected. I have given a minimum and maximum window size as well.
What can be the reason behind it? Can someone help me out?
Code:
Future<void> _setupDesktop() async {
const minimumWindowSize = Size(1100, 800);
await windowManager.ensureInitialized();
WindowManager.instance.setMinimumSize(minimumWindowSize);
WindowManager.instance
.setMaximumSize(const Size(double.infinity, double.infinity));
WindowOptions windowOptions = const WindowOptions(
size: minimumWindowSize,
center: true,
);
windowManager.waitUntilReadyToShow(windowOptions, () async {
await windowManager.show();
await windowManager.focus();
});
}
To fix this issue, I don't have to set the maximum size of the window as double.infinity. I removed this line
WindowManager.instance.setMaximumSize(const Size(double.infinity, double.infinity));
and it seems to work fine.
Reason (not sure, but this might be): Using double.infinity for setMaximumSize creates an infinite size limit, which can cause issues on Windows by making the window non-resizable. Windows may interpret this size as the window being at its maximum, preventing any resizing. On macOS, the system may handle it more gracefully, leading to different behaviors across platforms.