Skip to content

Commit ef668ab

Browse files
Merge pull request #32 from macosui/issues_22_and_31
Issues #22 and #31
2 parents f8d1dd8 + 7133825 commit ef668ab

File tree

6 files changed

+24
-2
lines changed

6 files changed

+24
-2
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 1.2.0
2+
3+
- Fix typo in README.
4+
- Add `isMainWindow` getter to WindowManipulator.
5+
16
## 1.1.3
27

38
- Fix multiple `FlutterViewController`s being created, which prevented the apps from exiting properly on Flutter 3.10.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ and the Flutter guide for
3333
+ Methods and widgets to add, remove, and modify visual effect subviews.
3434
+ Methods to set the window's level as well as reorder the window within its level.
3535
+ Methods to modify the window's style mask.
36-
+ An abstract `NSWindowDelegate` class that can be used detect `NSWindow` events, such as window resizing, moving, exposing, and minimizing.
36+
+ An abstract `NSWindowDelegate` class that can be used to detect `NSWindow` events, such as window resizing, moving, exposing, and minimizing.
3737
+ An `NSAppPresentationOptions` class that allows modifications to the window's fullscreen presentation options.
3838

3939
Additionally, the package ships with an example project that showcases the plugin's features via an intuitive searchable user interface:

lib/window_manipulator.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -651,4 +651,9 @@ class WindowManipulator {
651651
'`enableWindowDelegate` parameter is set to true in your '
652652
'WindowManipulator.initialize call.');
653653
}
654+
655+
static Future<bool> isMainWindow() async {
656+
await _completer.future;
657+
return await _windowManipulatorMethodChannel.invokeMethod('isMainWindow');
658+
}
654659
}

macos/Classes/MacOSWindowUtilsPlugin.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,10 @@ public class MacOSWindowUtilsPlugin: NSObject, FlutterPlugin {
413413

414414
result(MainFlutterWindowManipulator.addFullScreenPresentationOptions(presentationOptions!))
415415

416+
case "isMainWindow":
417+
let isMainWindow = MainFlutterWindowManipulator.isMainWindow()
418+
result(isMainWindow)
419+
416420
default:
417421
result(FlutterMethodNotImplemented)
418422
break

macos/Classes/MainFlutterWindowManipulator.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,4 +566,12 @@ public class MainFlutterWindowManipulator {
566566
mainFlutterWindowDelegate?.addFullScreenPresentationOptions(presentationOptions)
567567
return true
568568
}
569+
570+
public static func isMainWindow() -> Bool {
571+
if (self.mainFlutterWindow == nil) {
572+
start(mainFlutterWindow: nil)
573+
}
574+
575+
return self.mainFlutterWindow!.isMainWindow
576+
}
569577
}

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: macos_window_utils
22
description:
33
macos_window_utils is a Flutter package that provides a set of methods for
44
modifying the NSWindow of a Flutter application on macOS.
5-
version: 1.1.3
5+
version: 1.2.0
66
repository: https://github.com/Adrian-Samoticha/macos_window_utils.dart
77

88
environment:

0 commit comments

Comments
 (0)