closeWindow static method
Sends a message to close the window hosting your Flutter app.
- On Windows, it calls
PostMessage(handle, WM_CLOSE, 0, 0)
. See WM_CLOSE - On macOS, it calls -[NSWindow performClose:]
- On Linux, it calls gtk_window_close
- The method does not support Flutter Web.
Implementation
static Future<void> closeWindow() async {
if (kIsWeb) throw Exception('The method does not work in Flutter Web.');
await _initIfRequired();
await _channel.invokeMethod('closeWindow');
}