fix: macos, terminate, close main then remote windows (#8240)

* fix: macos, terminate, close main then remote windows

Signed-off-by: fufesou <linlong1266@gmail.com>

* comments

Signed-off-by: fufesou <linlong1266@gmail.com>

---------

Signed-off-by: fufesou <linlong1266@gmail.com>
This commit is contained in:
fufesou 2024-06-02 10:35:54 +08:00 committed by GitHub
parent b6ebf61d6c
commit 32346c23e0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2384,7 +2384,13 @@ Future<void> onActiveWindowChanged() async {
await windowManager.setPreventClose(false); await windowManager.setPreventClose(false);
await windowManager.close(); await windowManager.close();
if (isMacOS) { if (isMacOS) {
// If we call without delay, `flutter/macos/Runner/MainFlutterWindow.swift` can handle the "terminate" event.
// But the app will not close.
//
// No idea why we need to delay here, `terminate()` itself is also an async function.
Future.delayed(Duration.zero, () {
RdPlatformChannel.instance.terminate(); RdPlatformChannel.instance.terminate();
});
} }
} }
} }