This plugin allows Flutter desktop apps to defines system tray.

Last update: Aug 6, 2022

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.1.0

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(
  Platform.isWindows
    ? 'images/tray_icon.ico'
    : 'images/tray_icon.png',
);
List<MenuItem> items = [
  MenuItem(
    key: 'show_window',
    title: 'Show Window',
  ),
  MenuItem.separator,
  MenuItem(
    key: 'exit_app',
    title: 'Exit App',
  ),
];
await TrayManager.instance.setContextMenu(items);

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

Listening events

import 'package:flutter/material.dart';
import 'package:tray_manager/tray_manager.dart';


class HomePage extends StatefulWidget {
  @override
  _HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> with TrayListener {
  @override
  void initState() {
    TrayManager.instance.addListener(this);
    super.initState();
    _init();
  }

  @override
  void dispose() {
    TrayManager.instance.removeListener(this);
    super.dispose();
  }

  void _init() {
    // ...
  }

  @override
  Widget build(BuildContext context) {
    // ...
  }

  @override
  void onTrayIconMouseDown() {
    // do something
  }

  @override
  void onTrayIconRightMouseDown() {
    // do something
  }

  @override
  void onTrayIconRightMouseUp() {
    // do something
  }

  @override
  void onTrayMenuItemClick(MenuItem menuItem) {
    if (menuItem.key == 'show_window') {
      // do something
    } else if (menuItem.key == 'exit_app') {
       // do something
    }
  }
}

API

TrayManager

Method Description Linux macOS Windows
destroy Destroys the tray icon immediately. ✔️ ✔️ ✔️
setIcon Sets the image associated with this tray icon. ✔️ ✔️ ✔️
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 <[email protected]>

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.

GitHub

https://github.com/leanflutter/tray_manager
Comments
  • 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
    
    
    Reviewed by tatosjb at 2022-05-24 19:03
  • 2. [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.

    Reviewed by cbenhagen at 2022-03-13 17:09
  • 3. 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.

    Reviewed by redsolver at 2022-05-08 13:17
  • 4. 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.

    Reviewed by sufu777 at 2022-05-17 20:21
  • 5. 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.

    Reviewed by simonbengtsson at 2022-04-17 19:35
  • 6. 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?

    Reviewed by 15563988825 at 2022-02-25 03:57
  • 7. [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

    Reviewed by jeanantoine at 2022-02-07 13:01
  • 8. 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.

    Reviewed by dodatw at 2022-01-09 06:07
  • 9. 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
    
    Reviewed by j787701730 at 2022-01-08 06:28
  • 10. 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

    Reviewed by yahu1031 at 2022-06-11 17:11
  • 11. [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.

    Reviewed by jakub-stefaniak at 2022-01-25 12:11

Related

A Flutter package that makes it easy to customize and work with your Flutter desktop app's system tray.
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

Aug 1, 2022
This plugin allows Flutter desktop apps to Retrieve information about screen size, displays, cursor position, etc.

screen_retriever This plugin allows Flutter desktop apps to Retrieve information about screen size, displays, cursor position, etc. screen_retriever P

May 5, 2022
This plugin allows Flutter desktop apps to extract text from screen.

screen_text_extractor This plugin allows Flutter desktop apps to extract text from screen. screen_text_extractor Platform Support Quick Start Installa

Aug 5, 2022
This plugin allows Flutter desktop apps to resizing and repositioning the window.

window_manager This plugin allows Flutter desktop apps to resizing and repositioning the window. window_manager Platform Support Quick Start Installat

Aug 15, 2022
This plugin allows Flutter desktop apps to register and handle custom protocols

protocol_handler This plugin allows Flutter desktop apps to register and handle custom protocols (i.e. deep linking). English | 简体中文 protocol_handler

Jul 7, 2022
Build beautiful desktop apps with flutter and rust. 🌠 (wip)
Build beautiful desktop apps with flutter and rust. 🌠 (wip)

flutter-rs Build flutter desktop app in dart & rust. Get Started Install requirements Rust flutter sdk Develop install the cargo flutter command cargo

Aug 6, 2022
Build beautiful desktop apps with flutter and rust. 🌠
Build beautiful desktop apps with flutter and rust. 🌠

flutter-rs Build flutter desktop app in dart & rust. Get Started Install requirements Rust flutter sdk Develop install the cargo flutter command cargo

Aug 9, 2022
Flutter plugin for Flutter desktop(macOS/Linux/Windows) to change window size.

desktop_window Flutter plugin for Flutter desktop(macOS/Linux/Windows) to change window size. Usage import 'package:desktop_window/desktop_window.dart

Jul 11, 2022
File picker plugin for Flutter, compatible with mobile (iOS & Android), Web, Desktop (Mac, Linux, Windows) platforms with Flutter Go support.
File picker plugin for Flutter, compatible with mobile (iOS & Android), Web, Desktop (Mac, Linux, Windows) platforms with Flutter Go support.

A package that allows you to use the native file explorer to pick single or multiple files, with extensions filtering support.

Aug 14, 2022
An krunner plugin for changing kde plasma accent color from directly desktop

An krunner plugin for changing kde plasma accent color from directly desktop

Feb 21, 2022
Implements Microsoft's Fluent Design System in Flutter.
Implements Microsoft's Fluent Design System in Flutter.

fluent_ui Design beautiful native windows apps using Flutter Unofficial implementation of Fluent UI for Flutter. It's written based on the official do

Aug 10, 2022
Remote debugging system.

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

Oct 24, 2021
Online Crime Reporting System
 Online Crime Reporting System

Online Crime Reporting System This website develped for a DBMS course assignment, we uses dart , flutter , hostinger , phpmyadmin , mysql , for creati

Nov 25, 2021
A Flutter package that makes it easy to customize and work with your Flutter desktop app window.
A Flutter package that makes it easy to customize and work with your Flutter desktop app window.

bitsdojo_window A Flutter package that makes it easy to customize and work with your Flutter desktop app window on Windows, macOS and Linux. Watch the

Aug 5, 2022
A platform adaptive Flutter app for desktop, mobile and web.
A platform adaptive Flutter app for desktop, mobile and web.

Flutter Folio A demo app showcasing how Flutter can deliver a great multi-platform experience, targeting iOS, Android, MacOS, Windows, Linux, and web.

Aug 5, 2022
Pangolin Desktop UI shell, designed for dahliaOS, written in Flutter.
Pangolin Desktop UI shell, designed for dahliaOS, written in Flutter.

Website ● Discord ● Releases ● Donate ● Documentation Pangolin Desktop UI Pangolin UI is a Desktop shell for dahliaOS, written in Flutter, runs on Lin

Aug 11, 2022
Unofficial Ubuntu Desktop Settings App made with Flutter
 Unofficial Ubuntu Desktop Settings App made with Flutter

Unofficial Ubuntu Desktop Settings App made with Flutter - WIP The goal of this project is to build a feature complete settings app for the Ubuntu des

Aug 8, 2022
Simple file explorer for desktop made with Flutter, highly inspired by macOS Finder

file_explorer A basic file explorer made with Flutter Getting Started This project is a starting point for a Flutter application. A few resources to g

Nov 7, 2021
An 🎵 audio playback library for Flutter Desktop. Supports Windows & Linux. Based on miniaudio.
An 🎵 audio playback library for Flutter Desktop. Supports Windows & Linux. Based on miniaudio.

✒ libwinmedia is sequel to this project. It provides network playback, better format support, control & features. An audio playback library for Flutte

Jul 10, 2022