This plugin allows Flutter desktop apps to defines system tray.

Overview

tray_manager

pub version

This plugin allows Flutter desktop apps to defines system tray.

Discord


Platform Support

Linux macOS Windows
✔️ ✔️ ✔️

Quick Start

Installation

Add this to your package's pubspec.yaml file:

dependencies:
  tray_manager: ^0.0.2

Or

dependencies:
  tray_manager:
    git:
      url: https://github.com/leanflutter/tray_manager.git
      ref: main

⚠️ Linux requirements

  • appindicator3-0.1

Run the following command

sudo apt-get install appindicator3-0.1 libappindicator3-dev

Usage

Register/Unregsiter a system/inapp wide hot key.

import 'package:tray_manager/tray_manager.dart';

await TrayManager.instance.setIcon('images/tray_icon.png');
List<MenuItem> menuItems = [
  MenuItem(title: 'Show/Hide Main Window'),
  MenuItem.separator,
  MenuItem(title: 'Exit App'),
];
await TrayManager.instance.setContextMenu(menuItems);
await TrayManager.instance.popUpContextMenu();

Please see the example app of this plugin for a full example.

API

TrayManager

Method Description Linux macOS Windows
destroy Destroys the tray icon immediately. ✔️ ✔️ ✔️
setIcon Sets the image associated with this tray icon. ✔️ ✔️ ✔️
setToolTip - ✔️
setContextMenu - ✔️ ✔️ ✔️
popUpContextMenu Pops up the context menu of the tray icon. When menu is passed, the menu will be shown instead of the tray icon's context menu. ✔️ ✔️
getBounds Returns Rect The bounds of this tray icon. ✔️ ✔️ ✔️

License

MIT License

Copyright (c) 2021 LiJianying 
   
    

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

   
Issues
  • [linux] [error] clang: error: linker command failed with exit code 1

    [linux] [error] clang: error: linker command failed with exit code 1

    I get this error just trying to build the project after add the lib.

    personal_wallet flutter build linux -v

    personal_wallet flutter build linux -v
    [ +100 ms] executing: uname -m
    [  +31 ms] Exit code 0 from: uname -m
    [        ] x86_64
    [   +4 ms] executing: [/home/tato/snap/flutter/common/flutter/] git -c log.showSignature=false log -n 1 --pretty=format:%H
    [   +3 ms] Exit code 0 from: git -c log.showSignature=false log -n 1 --pretty=format:%H
    [        ] fb57da5f945d02ef4f98dfd9409a72b7cce74268
    [        ] executing: [/home/tato/snap/flutter/common/flutter/] git tag --points-at fb57da5f945d02ef4f98dfd9409a72b7cce74268
    [  +16 ms] Exit code 0 from: git tag --points-at fb57da5f945d02ef4f98dfd9409a72b7cce74268
    [        ] 3.0.1
    [  +12 ms] executing: [/home/tato/snap/flutter/common/flutter/] git rev-parse --abbrev-ref --symbolic @{u}
    [   +7 ms] Exit code 0 from: git rev-parse --abbrev-ref --symbolic @{u}
    [        ] origin/stable
    [        ] executing: [/home/tato/snap/flutter/common/flutter/] git ls-remote --get-url origin
    [   +6 ms] Exit code 0 from: git ls-remote --get-url origin
    [        ] https://github.com/flutter/flutter.git
    [  +87 ms] executing: [/home/tato/snap/flutter/common/flutter/] git rev-parse --abbrev-ref HEAD
    [   +3 ms] Exit code 0 from: git rev-parse --abbrev-ref HEAD
    [        ] stable
    [  +28 ms] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
    [        ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
    [        ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
    [        ] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
    [   +1 ms] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
    [        ] Artifact Instance of 'WindowsUwpEngineArtifacts' is not required, skipping update.
    [        ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
    [        ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
    [        ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
    [        ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
    [        ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
    [        ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
    [  +29 ms] Artifact Instance of 'MaterialFonts' is not required, skipping update.
    [        ] Artifact Instance of 'GradleWrapper' is not required, skipping update.
    [        ] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
    [        ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
    [        ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
    [        ] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
    [        ] Artifact Instance of 'FlutterSdk' is not required, skipping update.
    [        ] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
    [        ] Artifact Instance of 'WindowsUwpEngineArtifacts' is not required, skipping update.
    [        ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
    [        ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
    [        ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
    [        ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
    [        ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
    [        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
    [        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
    [        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
    [        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
    [        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
    [        ] Artifact Instance of 'FontSubsetArtifacts' is not required, skipping update.
    [        ] Artifact Instance of 'PubDependencies' is not required, skipping update.
    [  +26 ms] Skipping pub get: version match.
    [  +12 ms] Found plugin tray_manager at /home/tato/snap/flutter/common/flutter/.pub-cache/git/tray_manager-d7595175095e18213615c3237ced829979fa0b4d/
    [  +26 ms] Found plugin tray_manager at /home/tato/snap/flutter/common/flutter/.pub-cache/git/tray_manager-d7595175095e18213615c3237ced829979fa0b4d/
    [  +38 ms] Generating /home/tato/projects/personal_wallet/android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java
    [  +36 ms] 💪 Building with sound null safety 💪
    [   +4 ms] Building Linux application...
    [   +9 ms] executing: [build/linux/x64/release/] cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DFLUTTER_TARGET_PLATFORM=linux-x64 /home/tato/projects/personal_wallet/linux
    [  +22 ms] -- Configuring done
    [   +3 ms] -- Generating done
    [        ] -- Build files have been written to: /home/tato/projects/personal_wallet/build/linux/x64/release
    [   +4 ms] executing: ninja -C build/linux/x64/release install
    [   +4 ms] ninja: Entering directory `build/linux/x64/release'
    [+1366 ms] [1/7] Generating /home/tato/projects/personal_wallet/linux/flutter/ephemeral/libflutter_linux_gtk.so,
    /home/tato/projects/personal_wallet/linux/flutter/ephemeral/flutter_linux/fl_basic_message_channel.h, /home/tato/projects/personal_wallet/linux/flutter/ephemeral/flutter_linux/fl_binary_codec.h,
    /home/tato/projects/personal_wallet/linux/flutter/ephemeral/flutter_linux/fl_binary_messenger.h, /home/tato/projects/personal_wallet/linux/flutter/ephemeral/flutter_linux/fl_dart_project.h,
    /home/tato/projects/personal_wallet/linux/flutter/ephemeral/flutter_linux/fl_engine.h, /home/tato/projects/personal_wallet/linux/flutter/ephemeral/flutter_linux/fl_json_message_codec.h,
    /home/tato/projects/personal_wallet/linux/flutter/ephemeral/flutter_linux/fl_json_method_codec.h, /home/tato/projects/personal_wallet/linux/flutter/ephemeral/flutter_linux/fl_message_codec.h,
    /home/tato/projects/personal_wallet/linux/flutter/ephemeral/flutter_linux/fl_method_call.h, /home/tato/projects/personal_wallet/linux/flutter/ephemeral/flutter_linux/fl_method_channel.h,
    /home/tato/projects/personal_wallet/linux/flutter/ephemeral/flutter_linux/fl_method_codec.h, /home/tato/projects/personal_wallet/linux/flutter/ephemeral/flutter_linux/fl_method_response.h,
    /home/tato/projects/personal_wallet/linux/flutter/ephemeral/flutter_linux/fl_plugin_registrar.h, /home/tato/projects/personal_wallet/linux/flutter/ephemeral/flutter_linux/fl_plugin_registry.h,
    /home/tato/projects/personal_wallet/linux/flutter/ephemeral/flutter_linux/fl_standard_message_codec.h,
    /home/tato/projects/personal_wallet/linux/flutter/ephemeral/flutter_linux/fl_standard_method_codec.h, /home/tato/projects/personal_wallet/linux/flutter/ephemeral/flutter_linux/fl_string_codec.h,
    /home/tato/projects/personal_wallet/linux/flutter/ephemeral/flutter_linux/fl_value.h, /home/tato/projects/personal_wallet/linux/flutter/ephemeral/flutter_linux/fl_view.h,
    /home/tato/projects/personal_wallet/linux/flutter/ephemeral/flutter_linux/flutter_linux.h, _phony_
    [   +4 ms] [  +97 ms] executing: uname -m
    [        ] [  +35 ms] Exit code 0 from: uname -m
    [        ] [        ] x86_64
    [        ] [   +5 ms] executing: [/home/tato/snap/flutter/common/flutter/] git -c log.showSignature=false log -n 1 --pretty=format:%H
    [        ] [   +3 ms] Exit code 0 from: git -c log.showSignature=false log -n 1 --pretty=format:%H
    [        ] [        ] fb57da5f945d02ef4f98dfd9409a72b7cce74268
    [        ] [        ] executing: [/home/tato/snap/flutter/common/flutter/] git tag --points-at fb57da5f945d02ef4f98dfd9409a72b7cce74268
    [        ] [  +14 ms] Exit code 0 from: git tag --points-at fb57da5f945d02ef4f98dfd9409a72b7cce74268
    [        ] [        ] 3.0.1
    [        ] [   +6 ms] executing: [/home/tato/snap/flutter/common/flutter/] git rev-parse --abbrev-ref --symbolic @{u}
    [        ] [   +2 ms] Exit code 0 from: git rev-parse --abbrev-ref --symbolic @{u}
    [        ] [        ] origin/stable
    [        ] [        ] executing: [/home/tato/snap/flutter/common/flutter/] git ls-remote --get-url origin
    [        ] [   +2 ms] Exit code 0 from: git ls-remote --get-url origin
    [        ] [        ] https://github.com/flutter/flutter.git
    [        ] [  +29 ms] executing: [/home/tato/snap/flutter/common/flutter/] git rev-parse --abbrev-ref HEAD
    [        ] [   +2 ms] Exit code 0 from: git rev-parse --abbrev-ref HEAD
    [        ] [        ] stable
    [        ] [  +25 ms] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
    [        ] [        ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
    [        ] [        ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
    [        ] [        ] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
    [        ] [   +1 ms] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
    [        ] [        ] Artifact Instance of 'WindowsUwpEngineArtifacts' is not required, skipping update.
    [        ] [        ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
    [        ] [        ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
    [        ] [        ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
    [        ] [        ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
    [        ] [        ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
    [        ] [        ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
    [        ] [  +46 ms] Artifact Instance of 'MaterialFonts' is not required, skipping update.
    [        ] [        ] Artifact Instance of 'GradleWrapper' is not required, skipping update.
    [        ] [        ] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
    [        ] [        ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
    [        ] [        ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
    [        ] [        ] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
    [        ] [        ] Artifact Instance of 'FlutterSdk' is not required, skipping update.
    [        ] [        ] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
    [        ] [        ] Artifact Instance of 'WindowsUwpEngineArtifacts' is not required, skipping update.
    [        ] [        ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
    [        ] [        ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
    [        ] [        ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
    [        ] [        ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
    [        ] [        ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
    [        ] [        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
    [        ] [        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
    [        ] [        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
    [        ] [        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
    [        ] [        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
    [        ] [        ] Artifact Instance of 'FontSubsetArtifacts' is not required, skipping update.
    [        ] [        ] Artifact Instance of 'PubDependencies' is not required, skipping update.
    [        ] [  +18 ms] Initializing file store
    [        ] [   +3 ms] Done initializing file store
    [        ] [  +23 ms] Skipping target: gen_localizations
    [        ] [   +5 ms] Skipping target: gen_dart_plugin_registrant
    [        ] [ +134 ms] Skipping target: unpack_linux
    [        ] [ +196 ms] Skipping target: kernel_snapshot
    [        ] [  +13 ms] Skipping target: aot_elf_release
    [        ] [  +13 ms] Skipping target: linux_aot_bundle
    [        ] [  +24 ms] Skipping target: release_bundle_linux-x64_assets
    [        ] [        ] Persisting file store
    [        ] [   +4 ms] Done persisting file store
    [        ] [   +2 ms] build succeeded.
    [        ] [   +4 ms] "flutter assemble" took 505ms.
    [        ] [ +223 ms] ensureAnalyticsSent: 221ms
    [        ] [        ] Running shutdown hooks
    [        ] [        ] Shutdown hooks complete
    [        ] [        ] exiting with code 0
    [ +197 ms] [2/5] Building CXX object CMakeFiles/personal_wallet.dir/flutter/generated_plugin_registrant.cc.o
    [  +24 ms] [3/5] Building CXX object CMakeFiles/personal_wallet.dir/my_application.cc.o
    [ +118 ms] [4/5] Linking CXX executable intermediates_do_not_run/personal_wallet
    [        ] FAILED: intermediates_do_not_run/personal_wallet 
    [   +3 ms] : && /snap/flutter/current/usr/bin/clang++  -O3 -DNDEBUG  -B/snap/flutter/current/usr/lib/gcc/x86_64-linux-gnu/8 -B/snap/flutter/current/usr/lib/x86_64-linux-gnu
    -B/snap/flutter/current/lib/x86_64-linux-gnu -B/snap/flutter/current/usr/lib/ -L/snap/flutter/current/usr/lib/gcc/x86_64-linux-gnu/8 -L/snap/flutter/current/usr/lib/x86_64-linux-gnu
    -L/snap/flutter/current/lib/x86_64-linux-gnu -L/snap/flutter/current/usr/lib/ -lblkid -lgcrypt -llzma -llz4 -lgpg-error -luuid -lpthread -ldl -B/snap/flutter/current/usr/lib/gcc/x86_64-linux-gnu/8
    -B/snap/flutter/current/usr/lib/x86_64-linux-gnu -B/snap/flutter/current/lib/x86_64-linux-gnu -B/snap/flutter/current/usr/lib/ -L/snap/flutter/current/usr/lib/gcc/x86_64-linux-gnu/8
    -L/snap/flutter/current/usr/lib/x86_64-linux-gnu -L/snap/flutter/current/lib/x86_64-linux-gnu -L/snap/flutter/current/usr/lib/ -lblkid -lgcrypt -llzma -llz4 -lgpg-error -luuid -lpthread -ldl
    CMakeFiles/personal_wallet.dir/main.cc.o CMakeFiles/personal_wallet.dir/my_application.cc.o CMakeFiles/personal_wallet.dir/flutter/generated_plugin_registrant.cc.o  -o
    intermediates_do_not_run/personal_wallet  -Wl,-rpath,/home/tato/projects/personal_wallet/build/linux/x64/release/plugins/tray_manager:/home/tato/projects/personal_wallet/linux/flutter/ephemeral:
    plugins/tray_manager/libtray_manager_plugin.so /snap/flutter/current/usr/lib/x86_64-linux-gnu/libgtk-3.so /snap/flutter/current/usr/lib/x86_64-linux-gnu/libgdk-3.so
    /snap/flutter/current/usr/lib/x86_64-linux-gnu/libpangocairo-1.0.so /snap/flutter/current/usr/lib/x86_64-linux-gnu/libpango-1.0.so /snap/flutter/current/usr/lib/x86_64-linux-gnu/libatk-1.0.so
    /snap/flutter/current/usr/lib/x86_64-linux-gnu/libcairo-gobject.so /snap/flutter/current/usr/lib/x86_64-linux-gnu/libcairo.so /snap/flutter/current/usr/lib/x86_64-linux-gnu/libgdk_pixbuf-2.0.so
    /home/tato/projects/personal_wallet/linux/flutter/ephemeral/libflutter_linux_gtk.so /snap/flutter/current/usr/lib/x86_64-linux-gnu/libgio-2.0.so
    /snap/flutter/current/usr/lib/x86_64-linux-gnu/libgobject-2.0.so /snap/flutter/current/usr/lib/x86_64-linux-gnu/libglib-2.0.so && :
    [   +1 ms] //lib/x86_64-linux-gnu/libayatana-ido3-0.4.so.0: undefined reference to `g_time_zone_new_identifier'
    [        ] clang: error: linker command failed with exit code 1 (use -v to see invocation)
    [   +1 ms] ninja: build stopped: subcommand failed.
    [  +18 ms] Building Linux application... (completed in 1.768ms)
    [        ] "flutter linux" took 1.976ms.
    [   +7 ms] Build process failed
    [        ] 
               #0      throwToolExit (package:flutter_tools/src/base/common.dart:10:3)
               #1      _runBuild (package:flutter_tools/src/linux/build_linux.dart:186:5)
               <asynchronous suspension>
               #2      buildLinux (package:flutter_tools/src/linux/build_linux.dart:78:5)
               <asynchronous suspension>
               #3      BuildLinuxCommand.runCommand (package:flutter_tools/src/commands/build_linux.dart:85:5)
               <asynchronous suspension>
               #4      FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:1183:27)
               <asynchronous suspension>
               #5      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
               <asynchronous suspension>
               #6      CommandRunner.runCommand (package:args/command_runner.dart:209:13)
               <asynchronous suspension>
               #7      FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:281:9)
               <asynchronous suspension>
               #8      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
               <asynchronous suspension>
               #9      FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:229:5)
               <asynchronous suspension>
               #10     run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:62:9)
               <asynchronous suspension>
               #11     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
               <asynchronous suspension>
               #12     main (package:flutter_tools/executable.dart:94:3)
               <asynchronous suspension>
               
               
    [  +82 ms] ensureAnalyticsSent: 78ms
    [   +2 ms] Running shutdown hooks
    [        ] Shutdown hooks complete
    [        ] exiting with code 1
    
    
    opened by tatosjb 7
  • [macOS] onTrayIconMouseDown not triggered after long press

    [macOS] onTrayIconMouseDown not triggered after long press

    To reproduce:

    1. start the example app
    2. click setIcon and setContextMenu buttons
    3. click on tray icon for 1s
    4. menu opens on mouse down and closes automatically on mouse up as expected
    5. click tray icon again
    6. notice that mouse down is not handled

    Mostly the same happens if you you press the tray icon about 200ms. The menu will stay open but the next mouse down is not handled as well. The first example is just easier to reproduce but most likely due to the same issue.

    opened by cbenhagen 4
  • Library can't be loaded on Debian 11

    Library can't be loaded on Debian 11

    When trying to run a compiled application using this plugin on Debian 11, it crashes with error while loading shared libraries: libappindicator3.so.1: cannot open shared object file: No such file or directory This is likely caused by Debian removing libappindicator3-1 from their repositories because it's deprecated (https://www.reddit.com/r/debian/comments/pn1oia/what_happened_to_libappindicator31_in_debian_11/)

    The recommended solution is to switch to libayatana-appindicator3-1, but this change needs to be added to all applications. So I guess the best way to fix this plugin is to check if libayatana is available on the user's system and use that instead.

    opened by redsolver 3
  • popUpContextMenu does not work

    popUpContextMenu does not work

    TrayManager.instance.popUpContextMenu() does not work on windows 11? env: win11 Flutter 3.0.0 • channel stable • https://github.com/flutter/flutter.git Framework • revision ee4e09cce0 (8 days ago) • 2022-05-09 16:45:18 -0700 Engine • revision d1b9a6938a Tools • Dart 2.17.0 • DevTools 2.12.2

    my code:

    class _MyAppState extends State<MyApp> with TrayListener{
    
      @override
      void initState() {
        super.initState();
        initSystemTray();
        TrayManager.instance.addListener(this);
      }
    
      @override
      void dispose() {
        super.dispose();
        _timer?.cancel();
        TrayManager.instance.removeListener(this);
      }
    
      // 初始化菜单
      Future<void> initSystemTray() async {
        // 设置图标
        TrayManager.instance.setIcon(Platform.isWindows?'assets/tray_icon.ico':'assets/app_ico.png');
        List<MenuItem> menus = [
          MenuItem(key: "show_window",label: "打开窗口"),
          MenuItem.separator(),
          MenuItem(key: "exit",label: "退出")
        ];
        TrayManager.instance.setContextMenu(Menu(items: menus));
      }
    
    
      @override
      void onTrayIconMouseDown() {
        // windowManager.show();
        TrayManager.instance.popUpContextMenu();
      }
    
      @override
      Widget build(BuildContext context) {
        return const MaterialApp(
          debugShowCheckedModeBanner: false,
          home: Scaffold(
            body: Text("啦啦啦"),
          ),
        );
      }
    
      @override
      void onTrayIconRightMouseDown() {
        print("right mouse clicked");
        TrayManager.instance.popUpContextMenu();
      }
    
      @override
      void onTrayMenuItemClick(MenuItem menuItem) {
        if(menuItem.key == 'exit'){
          exit(0);
        }
      }
    }
    

    when right mouse down, it seems like main window was focused, but context mune does not pop up.just like this: o

    as the gif show, onTrayIconRightMouseDown was called and successed to print log, but TrayManager.instance.popUpContextMenu(); does not work.

    opened by sufu777 1
  • Fix flutter beta error regarding MenuItem import

    Fix flutter beta error regarding MenuItem import

    There is an error when using this library with the most recent flutter beta (2.13.0-0.1.pre) which can be fixed by simply removing an unused import of material.dart.

    The name 'MenuItem' is defined in the libraries 'package:flutter/src/widgets/platform_menu_bar.dart' and 
    'package:tray_manager/src/menu_item.dart (via package:tray_manager/tray_manager.dart)'
    

    An easy way for client code to fix this is to hide the MenuItem import from material if this is not needed.

    import 'package:flutter/material.dart' hide MenuItem;
    

    Basically the MenuItem class name collides with a new class in flutter which was added in this commit. There is some mentions of the plans for flutter to add native menu bar support in the flutter roadmap which can be read more about in this ticket https://github.com/flutter/flutter/issues/23600.

    opened by simonbengtsson 1
  • System close to tray

    System close to tray

    How to keep the app in system when close button is clicked Is it possible to override the close button so that when a user tries to close the app it just hides and remains in systemtray as background?

    opened by 15563988825 1
  • [macos] onTrayMenuItemClick not activated in master any more.

    [macos] onTrayMenuItemClick not activated in master any more.

    Hello,

    on macos in the example when using the package from pub: tray_manager: ^0.1.3

    void onTrayMenuItemClick(MenuItem menuItem) {
        print(menuItem.toJson());
        BotToast.showText(
          text: '${menuItem.toJson()}',
        );
      }
    

    onTrayMenuItemClick is activated when I select a menu item.

    When I use tray_manager from the master

    tray_manager:
      path: ../
    

    the example does not work any more.

    I use the master because of issue 4

    opened by jeanantoine 1
  • Need one more click on Macos system tray

    Need one more click on Macos system tray

    When user right click tray icon many times. Reproduce step:

    1. right click icon on tray icon
    2. right click again. (it wired from here, the tray icon still at select status)
    3. we need right click again to leave this status.

    I found biyi have same issue. other application did not have this issue.

    opened by dodatw 1
  • setToolTip error MissingPluginException(No implementation found for method setToolTip on channel tray_manager)

    setToolTip error MissingPluginException(No implementation found for method setToolTip on channel tray_manager)

    await TrayManager.instance.setToolTip("hello world");
    
    [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: MissingPluginException(No implementation found for method setToolTip on channel tray_manager)
    #0      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:175:7)
    <asynchronous suspension>
    #1      TrayManager.setToolTip (package:tray_manager/src/tray_manager.dart:116:5)
    <asynchronous suspension>
    #2      _MyAppState.setTray (package:task_reminder_flutter/main.dart:48:5)
    <asynchronous suspension>
    
    Flutter (Channel beta, 2.9.0-0.1.pre, on Microsoft Windows [Version 10.0.19044.1415], locale zh-CN)
        • Flutter version 2.9.0-0.1.pre at D:\flutter
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision 8f1f9c10f0 (3 weeks ago), 2021-12-14 13:41:48 -0800
        • Engine revision 234aca678a
        • Dart version 2.16.0 (build 2.16.0-80.1.beta)
        • DevTools version 2.9.1
    
    opened by j787701730 1
  • destroy() recreates a flashing icon (appends to an existing flashing icon)

    destroy() recreates a flashing icon (appends to an existing flashing icon)

    I created a flashing icon and when I call destroy, It stops the flashing icon at the current state and appends a new flashing icon.

    This is the result if I keep clicking the destroy button. The last(left one) is blinking and the rest are not.

    Screenshot 2022-06-11 at 10 40 10 PM

    opened by yahu1031 0
  • [linux] setting icon works, but only sometimes

    [linux] setting icon works, but only sometimes

    Hey, I ran into an issue testing the example project on a virtual machine running Ubuntu 20.04.3 LTS.

    I tested the app on 2 virtual machines on different PCs. One works like a charm and the other one shows the tray icon only sometimes.

    I tried launching the example app from the terminal on the problematic vm to see logs, and it throws: GLib-GIO-CRITICAL **: 16:15:43.425: g_dbus_proxy_new: assertion 'G_IS_DBUS_CONNECTION (connection)' failed whenever I try to set the tray icon.

    One PC has Intel CPU and the second one has AMD CPU. I don't know if that's relevant, but it works as expected on intel.

    opened by jakub-stefaniak 0
Releases(v0.1.8)
Owner
LeanFlutter
To make the flutter even simpler
LeanFlutter
A Flutter package that makes it easy to customize and work with your Flutter desktop app's system tray.

system_tray A Flutter package that that enables support for system tray menu for desktop flutter apps. on Windows, macOS and Linux. Features: - Modify

AnTler 103 Jun 24, 2022
This plugin allows Flutter desktop apps to Auto launch on startup / login.

This plugin allows Flutter desktop apps to Auto launch on startup / login.

LeanFlutter 28 Jun 18, 2022
Playbit System interface defines an OS-like computing platform which can be implemented on a wide range of hosts

PlaySys The Playbit System interface PlaySys defines an OS-like computing platform which can be implemented on a wide range of hosts like Linux, BSD,

Playbit 227 Jun 22, 2022
that's simple malware open your cd tray infinity written in c++

Tray Malware that's simple malware open your cd tray infinity written in c++ Which OS Work In Tray Malware Linux Setup Tray Malware sudo apt install m

sami 1 Dec 25, 2021
SDK for building cross-platform desktop apps in ANSI-C

NAppGUI Cross-Platform C SDK. Build portable desktop applications for Windows, macOS and Linux, using just C. Quick start in Windows Prerequisites Vis

Francisco García Collado 194 Jun 23, 2022
Native context menu for Flutter apps

native_context_menu Native context menu for flutter apps Installation flutter pub add native_context_menu Usage import 'package:native_context_menu/na

Andrei Lesnitsky 132 Jun 4, 2022
An app that allows you to edit/create apps in Dash

AppAdder On Ubuntu, have you ever run a program or AppImage and the app not had an icon? This is a personal pet peeve. I've used AppImageLauncher to i

Camden 5 Jun 25, 2022
Flutter-Clock-and-Reminder-App - a highly functional clock and reminder app developed on flutter framework.

clock_app A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started if thi

Umar Baloch 5 Dec 27, 2021
The package allows to use H3 library directly in your Flutter application

The package allows to use H3 library directly in your Flutter application

Ilya Beregovskiy 9 Jun 17, 2022
A desktop (supports macOS and Windows) implementation of uni_links plugin.

uni_links_desktop A desktop (supports macOS and Windows) implementation of uni_links plugin. uni_links_desktop Platform Support Quick Start Installati

LeanFlutter 10 May 23, 2022
A cross-platform (Android/iOS/Windows/macOS) cronet plugin for Flutter via `dart:ffi`

cronet_flutter A cross-platform (Android/iOS/Windows/macOS) cronet plugin for Flutter via dart:ffi

null 20 Jun 15, 2022
A Flutter Web Plugin to display Text Widget as Html for SEO purpose

SEO Renderer A flutter plugin (under development) to render text widgets as html elements for SEO purpose. Created specifically for issue https://gith

Sahdeep Singh 88 Jun 17, 2022
A new JS script plugin for flutter

js_script Run JS script. Usage // Create a JS context. JsScript script = JsScript(); // Define a class. var classInfo = ClassInfo<TestClass>( newI

null 5 Mar 8, 2022
A cross-platform flutter plugin for C/C++/ObjC crash report via Google Breakpad

quick_breakpad A cross-platform flutter plugin for C/C++/ObjC crash report via Google Breakpad Use breakpad for quick_breakpad_example $CLI_BREAKPAD i

Woodemi Co., Ltd 15 Apr 26, 2022
Flutter plugin serving utilities related to Windows taskbar. 💙

windows_taskbar Flutter plugin serving utilities related to Windows taskbar ?? Install dependencies: windows_taskbar: ^0.0.1 Demo Checkout the exam

Hitesh Kumar Saini 83 Jun 25, 2022
Dwm_lut - Apply 3D LUTs to the Windows desktop for system-wide color correction/calibration

About This tool applies 3D LUTs to the Windows desktop by hooking into DWM. It works in both SDR and HDR modes, and uses tetrahedral interpolation on

null 127 Jun 25, 2022
mini-plugin host as plugin

DISTRHO Ildaeil DISTRHO Ildaeil is mini-plugin host working as a plugin, allowing one-to-one plugin format reusage. Load a VST2 plugin inside a LV2 ho

DISTRHO 40 Jun 25, 2022
A set of very empty header files that can be used when building apps with Cosmopolitan

cosmo-include A set of very empty header files that can be used when building apps with Cosmopolitan Why? When you build an application with Cosmopoli

null 18 May 9, 2022
Demonstrates implementation of the Windows 10 Acrylic Effect on C++ Win32 Apps using DWM Private APIs and Direct Composition

Win32 Acrylic Effect A Demonstration of Acrylic Effect on C++ Win32 applications using Direct Composition and DWM private APIs. Table of Contents Over

Selastin 91 Jun 13, 2022