Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

maximize() not working #412

Open
maxfornacon opened this issue Oct 19, 2023 · 3 comments
Open

maximize() not working #412

maxfornacon opened this issue Oct 19, 2023 · 3 comments

Comments

@maxfornacon
Copy link

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.

@erickib
Copy link

erickib commented Jan 7, 2024

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.

@trungtin0012
Copy link

trungtin0012 commented Feb 17, 2024

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);
}

@Kinwailo
Copy link

I add a delay to call the maximize method:

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants