File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -25,15 +25,29 @@ void main() async {
2525 runApp (const App ());
2626}
2727
28+ class MacWindowListener extends WindowListener {
29+ @override
30+ void onWindowClose () async {
31+ // On macOS, hide the window instead of closing it
32+ if (Platform .isMacOS) {
33+ await windowManager.hide ();
34+ }
35+ }
36+ }
37+
2838Future <void > initWindowManager () async {
2939 await windowManager.ensureInitialized ();
3040 WindowOptions windowOptions = const WindowOptions (
3141 size: Size (1000 , 780 ),
3242 );
3343 windowManager.waitUntilReadyToShow (
3444 windowOptions,
35- () {
36- windowManager.setTitle ("IRNet: freedom does not have a price" );
45+ () async {
46+ await windowManager.setTitle ("IRNet: freedom does not have a price" );
47+ // On macOS, add window listener to handle close button
48+ if (Platform .isMacOS) {
49+ windowManager.addListener (MacWindowListener ());
50+ }
3751 },
3852 );
3953}
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ import FlutterMacOS
44@main
55class AppDelegate : FlutterAppDelegate {
66 override func applicationShouldTerminateAfterLastWindowClosed( _ sender: NSApplication ) -> Bool {
7- return true
7+ return false
88 }
99
1010 override func applicationSupportsSecureRestorableState( _ app: NSApplication ) -> Bool {
You can’t perform that action at this time.
0 commit comments