window_manager icon indicating copy to clipboard operation
window_manager copied to clipboard

maximize() not working

Open maxfornacon opened this issue 10 months ago • 3 comments

windowManager.maximize() is not working.

I use it like this: It appears to be maximized for a short time, but then immediately returns to its default size.

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await windowManager.ensureInitialized();

  windowManager.waitUntilReadyToShow(null, () async {
    await windowManager.maximize();
    await windowManager.show();
    await windowManager.focus();
  });
  runApp(const MyApp());
}

Tested on Windows 10 with Flutter 3.13.7.

maxfornacon avatar Oct 19 '23 20:10 maxfornacon

Same problem here using Windows 11 Pro, but I don't think is related to the system. Maybe windowmanager is been called again and setting the size somehow.

erickib avatar Jan 07 '24 15:01 erickib

After some searching, I have found a workaround. You need to update in windows/runner/win32_window.cpp by changing the parameter in the ShowWindow function from SW_SHOWNORMAL to SW_MAXIMIZE (https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-showwindow).

bool Win32Window::Show() {
  return ShowWindow(window_handle_, SW_MAXIMIZE);
}

trungtin0012 avatar Feb 17 '24 07:02 trungtin0012

I add a delay to call the maximize method:

Future.delayed(Durations.long4, () {
  if (Settings.maximize.val) windowManager.maximize();
});

Kinwailo avatar Mar 28 '24 10:03 Kinwailo