close method
Try to close the window.
With setPreventClose on, the window stays and the listeners get
onWindowClose, as for the title bar's close button.
Implementation
Future<void> close() async {
final window = _target;
final closing =
window != null &&
(tryNative(() {
if (!nativeapi.Window.isCloseSupported()) return false;
_wireNativeEvents();
return window.close();
}) ??
false);
if (!closing) {
// Without a native close, as on a platform the core cannot close a
// window on, prevent-close still reports and otherwise the app quits.
final destroying = _isDestroying;
_isDestroying = false;
if (!destroying) {
_emit(kWindowEventClose);
if (_isPreventClose) return;
}
tryNative(() => nativeapi.Application.instance.quit(0));
}
}