-
-
Notifications
You must be signed in to change notification settings - Fork 275
Open
Description
Description
The app crashes when attempting to hide the window using windowManager.hide() after registering a system-wide hotkey with hotkey_manager. The crash occurs specifically when toggling the window visibility with Cmd+T.
Code Snippet
import 'dart:ui';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:window_manager/window_manager.dart';
import 'package:hotkey_manager/hotkey_manager.dart';
final showAndFocusWindowHotKey = HotKey(
key: PhysicalKeyboardKey.keyT,
modifiers: [HotKeyModifier.meta],
scope: HotKeyScope.system,
);
class AppShortcuts extends StatefulWidget {
const AppShortcuts({super.key, required this.child});
final Widget child;
@override
State<AppShortcuts> createState() => _AppShortcutsState();
}
class _AppShortcutsState extends State<AppShortcuts> {
@override
void initState() {
super.initState();
hotKeyManager.register(
showAndFocusWindowHotKey,
keyDownHandler: (hotKey) async {
if (!await windowManager.isVisible()) {
print('show and focus window');
windowManager.show();
windowManager.focus();
} else {
print('hide window');
windowManager.blur();
await windowManager.hide(); // Crash occurs here
}
},
);
}
@override
Widget build(BuildContext context) {
return widget.child;
}
}Steps to Reproduce
- Run the app
- Press Cmd+T to show the window
- Press Cmd+T again to hide the window
- App crashes when attempting to hide
Expected Behavior
The window should toggle visibility smoothly when pressing Cmd+T, showing when hidden and hiding when visible.
Actual Behavior
The app crashes when attempting to hide the window.
Environment
- Flutter SDK: ^3.7.2
- window_manager: ^0.4.3
- hotkey_manager: ^0.2.3
- Platform: macOS
Additional Notes
The crash seems to be related to the interaction between hotkey_manager and window_manager when attempting to hide the window. The show and focus operations work correctly, but the hide operation causes the app to crash.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels