systemTray.initSystemTray = Close Program
softplaceio opened this issue · comments
Hello, guys!
I just copied the Github code of the example and include a try/catch.
When it enters the line: Below the program closes alone.
Await systemtray.initsystemtray (title: "System tray," iconpath: Path, Tooltip: 'Test');
VSCODE -> Debug Console
Launching LIB/MAIN.dart on Linux in Debug Mode ...
main.dart: 1
Connecting to VM Service at WS: //127.0.0.1: 43941/ys2xpakwnnq =/WS
Method Call Initappwindow
Method Call initsystemtray
Lost Connection to Device.
My pubspec.yaml
assets:
- assets/
MyCode
Future<void> initSystemTray() async {
String path = Platform.isWindows ? 'assets/zip.ico' : 'assets/zip.png';
final AppWindow appWindow = AppWindow();
final SystemTray systemTray = SystemTray();
// We first init the systray menu
try {
await systemTray.initSystemTray(title: "system tray", iconPath: path, toolTip: 'test');
} catch (err) {
debugPrint("Err: $err");
}
// create context menu
final Menu menu = Menu();
await menu.buildFrom([
MenuItemLabel(label: 'Show', onClicked: (menuItem) => appWindow.show()),
MenuItemLabel(label: 'Hide', onClicked: (menuItem) => appWindow.hide()),
MenuItemLabel(label: 'Exit', onClicked: (menuItem) => appWindow.close()),
]);
// set context menu
await systemTray.setContextMenu(menu);
// handle system tray event
systemTray.registerSystemTrayEventHandler((eventName) {
debugPrint("eventName: $eventName");
if (eventName == kSystemTrayEventClick) {
Platform.isWindows ? appWindow.show() : systemTray.popUpContextMenu();
} else if (eventName == kSystemTrayEventRightClick) {
Platform.isWindows ? systemTray.popUpContextMenu() : appWindow.show();
}
});
}
Same here, ArchLinux
method call InitSystemTray
[1] 3422 segmentation fault (core dumped)