window_manager
window_manager copied to clipboard
[Windows] windowManager.close() does not close the window
For some reason, windowManager.close()
does not close the window for my flutter project. I downloaded your example, and it works fine there, but is there any reason that something might cause it not to work?
Flutter Doctor -v
[√] Flutter (Channel stable, 3.13.0, on Microsoft Windows [Version 10.0.22621.2134], locale en-US)
• Flutter version 3.13.0 on channel stable at C:\Users\Elias\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision efbf63d9c6 (5 days ago), 2023-08-15 21:05:06 -0500
• Engine revision 1ac611c64e
• Dart version 3.1.0
• DevTools version 2.25.0
[√] Windows Version (Installed version of Windows is version 10 or higher)
[√] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
• Android SDK at C:\Users\Elias\AppData\Local\Android\sdk
• Platform android-33, build-tools 33.0.1
• Java binary at: C:\Program Files\Android\Android Studio1\jbr\bin\java
• Java version OpenJDK Runtime Environment (build 17.0.6+0-b2043.56-9586694)
• All Android licenses accepted.
[√] Chrome - develop for the web
• Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe
[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.4.3)
• Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
• Visual Studio Community 2022 version 17.4.33205.214
• Windows 10 SDK version 10.0.22000.0
[!] Android Studio (version 2021.3)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin can be installed from:
https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
https://plugins.jetbrains.com/plugin/6351-dart
X Unable to determine bundled Java version.
• Try updating or re-installing Android Studio.
[√] Android Studio (version 2022.2)
• Android Studio at C:\Program Files\Android\Android Studio1
• Flutter plugin can be installed from:
https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 17.0.6+0-b2043.56-9586694)
[√] VS Code (version 1.81.1)
• VS Code at C:\Users\Elias\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.70.0
[√] Connected device (3 available)
• Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.22621.2134]
Quit on close If you need to use the hide method, you need to disable QuitOnClose.
macOS Change the file macos/Runner/AppDelegate.swift as follows:
import Cocoa
import FlutterMacOS
@NSApplicationMain
class AppDelegate: FlutterAppDelegate {
override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
- return true
+ return false
}
}
Did you follow this?
@JasCodes This is not for macOS, macOS closes fine; it is just Windows. I am not 100% sure the issue is this package, it throws no errors so I am having a hard time troubleshooting it.
How to disable the QuitOnClose?
Hello, I was also experiencing this issue until I found that you need to add listener for windowManager in the initstate and also add a dispose method. So check your code for it.
你好,有人知道如何在Linux上禁用QuitOnClose吗
On windows make sure you set quitOnCloase to true.
windows/runner/main.cpp
window.SetQuitOnClose(true);
and you don't prevent the close in your dart code
void _init() async {
// Must not be set to true
// await windowManager.setPreventClose(true);
setState(() {});
}