SyncNativeBridge class
High-level Dart API for synchronous FFI calls.
Wraps the generated FFIBindings with a more ergonomic interface,
handling pointer allocation/deallocation automatically.
This is different from NativeBridge in the bridge module which uses async MethodChannel. This class provides synchronous calls for time-critical operations like window resizing during layout.
Usage:
final bridge = SyncNativeBridge.instance;
// Get cursor position synchronously
final cursor = bridge.getCursorPosition();
print('Cursor at: ${cursor.x}, ${cursor.y}');
// Resize window synchronously (for SizeReporter)
bridge.resizeWindow('my-palette', 400, 300);
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- isAvailable → bool
-
Whether the native bridge is available.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
getActiveAppBounds(
) → NativeRect? - Get the bounds of the frontmost application window.
-
getActiveAppIdentifier(
) → String? - Get the bundle identifier of the active application.
-
getCursorPosition(
) → Point - Get the current cursor position in screen coordinates.
-
getCursorScreen(
) → int - Get the screen index where the cursor is located.
-
getScreenBounds(
int screenIndex) → NativeRect? - Get the full bounds of a screen (including menu bar, dock).
-
getScreenCount(
) → int - Get the number of connected screens.
-
getScreenScaleFactor(
int screenIndex) → double - Get the scale factor of a screen.
-
getScreenVisibleBounds(
int screenIndex) → NativeRect? - Get the visible bounds of a screen (excluding menu bar, dock, taskbar).
-
getWindowFrame(
String windowId) → NativeRect? - Get the current frame of a palette window.
-
isWindowVisible(
String windowId) → bool - Check if a palette window is currently visible.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
resizeWindow(
String windowId, double width, double height) → void - Resize a palette window synchronously.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- instance → SyncNativeBridge
-
Singleton instance of the native bridge.
no setter