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

setMinimumSize not working on macOS #335

Closed
git-n-pissed opened this issue May 5, 2023 · 6 comments
Closed

setMinimumSize not working on macOS #335

git-n-pissed opened this issue May 5, 2023 · 6 comments

Comments

@git-n-pissed
Copy link

The following code is being called in the main method right before runApp is called:

  // Don't allow the app window to be too small
  if(Platform.isWindows || Platform.isMacOS) {
    await windowManager.setMinimumSize(const Size(640, 480));
  }

Works as expected on Windows, but results in this error on macOS:

window_manager/WindowManager.swift:44: Fatal error: Unexpectedly found nil while unwrapping an Optional value

@damywise
Copy link
Contributor

damywise commented May 9, 2023

Hey, would you mind sharing a minimum reproducible example with me?
Also, have you checked if the one in the example works as expected?
I'm unable to reproduce this in MacOS Ventura 13.2.1 (22D68).
Thanks!

@temeddix
Copy link

temeddix commented Jun 5, 2023

Having the same issue here, I'm using macOS Ventura 13.2.1 on macbook pro 15-inch 2017. Flutter version is 3.10. For me, using any method of windowManager creates this error, not only setMinimumSize.

image

@temeddix
Copy link

temeddix commented Jun 5, 2023

I tried changing versions.

On 0.3.0

window_manager/WindowManager.swift:44: Fatal error: Unexpectedly found nil while unwrapping an Optional value

0.3.4

window_manager/WindowManager.swift:60: Fatal error: Unexpectedly found nil while unwrapping an Optional value

@temeddix
Copy link

temeddix commented Jun 5, 2023

Could it be the latest Flutter 3.10 causing this issue?

@temeddix
Copy link

temeddix commented Jun 5, 2023

Oops, it was because I missed out the following line:

await windowManager.ensureInitialized();

So this is not a bug, it's a mistake. After I added this line, it works like a charm.

@git-n-pissed
Copy link
Author

Oops, it was because I missed out the following line:

await windowManager.ensureInitialized();

So this is not a bug, it's a mistake. After I added this line, it works like a charm.

I haven't used that line before (doesn't appear to be needed for Android or Windows builds). I had switched to desktop_window package, but I'll try window_manager again and use ensureInitialized to see if that fixes the issue for me as well.

@lijy91 lijy91 closed this as completed Jan 28, 2024
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