A Flutter package that makes it easy to customize and work with your Flutter desktop app's system tray.

Overview

system_tray

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

Features:

- Modify system tray title/icon/tooltip
- Handle system tray event leftMouseUp/rightMouseUp (only for macos、windows)

Getting Started

Install the package using pubspec.yaml

For Windows

For macOS

For Linux

API

Below we show how to use system_tray

Future<void> initSystemTray() async {
    String path;
    if (Platform.isWindows) {
      path = p.joinAll([
        p.dirname(Platform.resolvedExecutable),
        'data/flutter_assets/assets',
        'app_icon.ico'
      ]);
    } else if (Platform.isMacOS) {
      path = p.joinAll(['AppIcon']);
    } else {
      path = p.joinAll([
        p.dirname(Platform.resolvedExecutable),
        'data/flutter_assets/assets',
        'app_icon.png'
      ]);
    }

    // We first init the systray menu and then add the menu entries
    await _systemTray.initSystemTray("system tray",
        iconPath: path, toolTip: "How to use system tray with Flutter");

    await _systemTray.setContextMenu(
      [
        MenuItem(
          label: 'Show',
          onClicked: () {
            appWindow.show();
          },
        ),
        MenuSeparator(),
        SubMenu(
          label: "SubMenu",
          children: [
            MenuItem(
              label: 'SubItem1',
              enabled: false,
              onClicked: () {
                print("click SubItem1");
              },
            ),
            MenuItem(label: 'SubItem2'),
            MenuItem(label: 'SubItem3'),
          ],
        ),
        MenuSeparator(),
        MenuItem(
          label: 'Exit',
          onClicked: () {
            appWindow.close();
          },
        ),
      ],
    );

    // flash tray icon
    _timer = Timer.periodic(
      const Duration(milliseconds: 500),
      (timer) {
        _toogleTrayIcon = !_toogleTrayIcon;
        _systemTray.setSystemTrayInfo(
          iconPath: _toogleTrayIcon ? "" : path,
        );
      },
    );

    // handle system tray event
    _systemTray.registerSystemTrayEventHandler((eventName) {
      print("eventName: $eventName");
    });
  }
Comments
  • example won't build for linux

    example won't build for linux

    CMake Error at /snap/flutter/91/usr/share/cmake-3.10/Modules/FindPkgConfig.cmake:415 (message): A required package was not found Call Stack (most recent call first): /snap/flutter/91/usr/share/cmake-3.10/Modules/FindPkgConfig.cmake:593 (_pkg_check_modules_internal) flutter/ephemeral/.plugin_symlinks/system_tray/linux/CMakeLists.txt:10 (pkg_check_modules)

    opened by sgehrman 8
  • keep app open in tray when window closed

    keep app open in tray when window closed

    Hey! Super useful plugin!

    One value in having the tray icon is that if someone closes the window of the application (with the close button or command + q) the app will still appear in the tray and can be opened by clicking the tray icon. Is there a way to do this using the plugin?

    Thanks!

    opened by Nealsoni00 5
  • Show window on tray click (no menu)

    Show window on tray click (no menu)

    Hey! Very useful plugin! -- I just wanted to see if there is a way to show the app directly when they press the tray icon? I ideally would want to show the menu options when they right-click the tray icon.

    opened by Nealsoni00 5
  • Running Flutter app in release / compiled mode doesn't always show the icon in the system tray

    Running Flutter app in release / compiled mode doesn't always show the icon in the system tray

    I have downloaded the repository and have run the example app. In debug, the system tray icon seems to always appear, but when I run in release mode, or do a "flutter build windows" and run the resulting executable, sometimes the icon shows, other times not - even though I do see the .exe process running in the task manager. Is there any way to troubleshoot/debug what's happening in the instances where the icon doesn't show?

    I'm running version ^0.1.1 on Windows 10, Flutter 3.0.1

    opened by Kevin-McKee 4
  • build error on flutter 2.13.0-0.3.pre

    build error on flutter 2.13.0-0.3.pre

    system_tray-0.1.0/lib/src/tray.dart:9:1: Error: 'MenuItem' is imported from both 'package:flutter/src/widgets/platform_menu_bar.dart' and 'package:system_tray/src/menu_item.dart'.

    opened by qcdong2016 3
  • The example app does not show system tray menu on macOS.

    The example app does not show system tray menu on macOS.

    Clicking a tray menu icon triggers the event handler with eventName = "leftMouseUp", but does not show system tray menu. (I might misunderstanding something.)

    It occurs on:

    • MacBook Pro Intel Core i7
    • macOS 11.0.1
    • Flutter 2.5.1
    opened by tomoyuki28jp 3
  • Dispose tray icon

    Dispose tray icon

    When the application closes, the icon remains in the tray until you hover over it. I would like to be able to delete it as needed, or at least when the application closes

    opened by AppetiteTeam 2
  • Hot reloading an app using AppWindow  raises a warning.

    Hot reloading an app using AppWindow raises a warning.

    Hot reloading an app using AppWindow on macOS raises a following warning:

    Error: Message responses can be sent only once. Ignoring duplicate response on channel 'flutter[/system_tray/app_window]()'.
    

    This occurs in the example app too.

    opened by tomoyuki28jp 1
  • Remove swift print log code

    Remove swift print log code

    When I update my system tray menu on macOS every 5 seconds to show elapsed time, my debug console is flooed with following messages:

    method: SetContextMenu
    method: SetSystemTrayInfo
    method: SetContextMenu
    method: SetSystemTrayInfo
    method: SetContextMenu
    method: SetSystemTrayInfo
    method: SetContextMenu
    method: SetSystemTrayInfo
    method: SetContextMenu
    method: SetSystemTrayInfo
    method: SetContextMenu
    method: SetSystemTrayInfo
    method: SetContextMenu
    method: SetSystemTrayInfo
    method: SetContextMenu
    method: SetSystemTrayInfo
    method: SetContextMenu
    

    Maybe we don't need the debug print code any more? if you want to keep printing them, I think it’s better to surround the print with If DEBUG clause so that the log message won’t be shown in production apps.

    #if DEBUG
      print("method: \(call.method)")
    #endif
    
    opened by tomoyuki28jp 1
  • System tray don't show

    System tray don't show

    I ran the sample code successfully, but did not see the system tray, please help.

    image

    flutter doctor
    Flutter assets will be downloaded from https://storage.flutter-io.cn. Make sure you trust this source!
    Doctor summary (to see all details, run flutter doctor -v):
    [✓] Flutter (Channel stable, 2.10.0, on Microsoft Windows [Version 10.0.22000.434], locale zh-CN)
    [✓] Android toolchain - develop for Android devices (Android SDK version 32.0.0)
    [✗] Chrome - develop for the web (Cannot find Chrome executable at .\Google\Chrome\Application\chrome.exe)
        ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
    [✓] Visual Studio - develop for Windows (Visual Studio Community 2022 17.0.5)
    [✓] Android Studio (version 2020.3)
    [✓] IntelliJ IDEA Ultimate Edition (version 2021.3)
    [✓] Connected device (3 available)
    
    opened by monkeyWie 1
  • There is no tooltip

    There is no tooltip

    Everything works fine except when i call _systemTray.setSystemTrayInfo(title: "Test info 1"); there is no tooltip at all. Maybe that is related to my OS, I am using Win 11.

    Not sure if that can help but in other package it is woriking.

    opened by infodusha 1
  • libappindicator not working for Ubuntu 22.04.1 LTS, and for snapcraft also

    libappindicator not working for Ubuntu 22.04.1 LTS, and for snapcraft also

    Reading package lists... Done Building dependency tree... Done Reading state information... Done Note, selecting 'monodoc-appindicator3-0.1-manual' for regex 'appindicator3-0.1' Note, selecting 'libayatana-appindicator3-0.1-cil' for regex 'appindicator3-0.1' Note, selecting 'libappindicator3-0.1-cil-dev' for regex 'appindicator3-0.1' Note, selecting 'libappindicator3-0.1-cil' for regex 'appindicator3-0.1' Note, selecting 'libayatana-appindicator3-0.1-cil-dev' for regex 'appindicator3-0.1' Note, selecting 'gir1.2-appindicator3-0.1' for regex 'appindicator3-0.1' Note, selecting 'gir1.2-ayatanaappindicator3-0.1' for regex 'appindicator3-0.1' gir1.2-ayatanaappindicator3-0.1 is already the newest version (0.5.90-7ubuntu2). gir1.2-appindicator3-0.1 is already the newest version (12.10.1+20.10.20200706.1-0ubuntu1). libappindicator3-0.1-cil is already the newest version (12.10.0+git20151221-5.1). libappindicator3-0.1-cil-dev is already the newest version (12.10.0+git20151221-5.1). libayatana-appindicator3-0.1-cil is already the newest version (0.5.90-7ubuntu2). libayatana-appindicator3-0.1-cil-dev is already the newest version (0.5.90-7ubuntu2). monodoc-appindicator3-0.1-manual is already the newest version (12.10.0+git20151221-5.1). Some packages could not be installed. This may mean that you have requested an impossible situation or if you are using the unstable distribution that some required packages have not yet been created or been moved out of Incoming. The following information may help to resolve the situation:

    The following packages have unmet dependencies: libappindicator3-dev : Depends: libappindicator3-1 (= 12.10.1+20.10.20200706.1-0ubuntu1) E: Unable to correct problems, you have held broken packages.

    opened by PrashantSaxenaV6001 0
  • Set tray icon from network and other sources

    Set tray icon from network and other sources

    Currently, the only way to set the tray icon is by providing an icon from the assets directory

    systemTray.setImage('assets/some_icon.ico');
    

    Can you make it possible to set the icon from other sources like Network and Memory?

    opened by javaherisaber 0
  • Usage section on pub.dev outdated

    Usage section on pub.dev outdated

    The Usage section on https://pub.dev/packages/system_tray seems outdated and not working, it references MenuItem, but example uses MenuItemLabel (which does not throw an error)

    opened by pokonski 0
  • Adaptive Status Bar Icon

    Adaptive Status Bar Icon

    The icon doesn't change color when the status bar changes color. In macos, you set a menuitem image from an asset to enable adaptive icons (black / white status bar toggle) Adding a channel for the following code allows for use of the asset

    func setStatusBarImage(_ call: FlutterMethodCall, _ result: FlutterResult) { let assetName = call.arguments as? String if assetName != nil { statusItem?.button?.image = NSImage.init(named: assetName!) result(true) } result(false) }

    opened by smpgallagher 2
  • Is anyone else experiencing their app hanging when their PC comes back from

    Is anyone else experiencing their app hanging when their PC comes back from "sleep"?

    I have an app written with this plugin, and everything works fine - except whenever my computer goes to sleep, then wakes up - my app is hung. I have to end task, then relaunch for it to work again. Is there something in this plugin related to sleep/wake that might be causing me trouble?

    opened by Kevin-McKee 0
Releases(v0.1.1)
Owner
AnTler
AnTler
This plugin allows Flutter desktop apps to defines system/inapp wide hotkey (i.e. shortcut).

hotkey_manager This plugin allows Flutter desktop apps to defines system/inapp wide hotkey (i.e. shortcut). hotkey_manager Platform Support Quick Star

LeanFlutter 82 Jan 6, 2023
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 45 Dec 18, 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
A Lilu plugin that makes System Information recognize your Realtek card reader as a native one

Realtek Card Reader Driver Friend Introduction A Lilu plugin that makes System Information recognize your Realtek card reader as a native one. Support

FireWolf 57 Nov 30, 2022
A npm package that lets you automate your windows desktop.

js-macro A npm package that lets you automate your windows desktop. npm i js-macro Examples Simple cursor usage const { cursor } = require("js-macro"

5 Jul 30, 2022
A npm package that lets you automate your windows desktop.

js-macro A npm package that lets you automate your windows desktop. npm i js-macro Examples Simple cursor usage const { cursor } = require("js-macro"

5 Jul 30, 2022
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 242 Jan 2, 2023
A module for Godot 3.x that makes it easy to send crash reports to Backtrace

Godot Backtrace Module This module adds automatic crash generation support to Godot 3.x with the intent of making it possible to send the crash data t

null 15 Oct 28, 2022
Handcrafted Flutter application well organized and easy to understand and easy to use.

Handcrafted Flutter application well organized and easy to understand and easy to use.

Justin Dah-kenangnon 2 Feb 1, 2022
A package to use Material side sheet into your Flutter project. Learn more about side sheet at Material.io

Side Sheet A package to use Material side sheet into your Flutter project. Learn more about side sheet at Material.io Platform Support Android iOS Mac

Lalit Jarwal 6 Aug 25, 2022
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 12 Dec 21, 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 151 Dec 22, 2022
A modern-day Boss Key software tool. Switch instantly from work to play & play to work with Bosky.

Bosky By: Seanpm2001, Bosky-dev Et; Al. Top README.md Read this article in a different language Sorted by: A-Z Sorting options unavailable ( af Afrika

Sean P. Myrick V19.1.7.2 2 Sep 10, 2022
Flutter app where you can find your information about your Favorite Super Cars ⚡❤

Super Cars App (Flutter) ⚡ Now you can freely discover and browse your Favourite Super Cars ❤ . Speed! ?? Getting Started This project is a starting p

Shehroz Ali 4 Apr 13, 2022
Lock you keyboard and clean your screen. A simple, and easy way to clean your computers.

Pristine Cleaner A screen and keyboard cleaning application made to turn screen black, and lock keyboard for easy cleaning. With features such as star

Rhino Inani 2 Jan 16, 2022
Add virtual monitors to your windows 10 device! Works with Oculus software, obs, and any desktop sharing software

License MIT and CC0 or Public Domain, whichever is least restrictive -- Use it AS IS - NO IMPLICIT OR EXPLICIT warranty This may break your computer,

Rashi Abramson 230 Jan 6, 2023
Hobbyist Operating System targeting x86_64 systems. Includes userspace, Virtual File System, An InitFS (tarfs), Lua port, easy porting, a decent LibC and LibM, and a shell that supports: piping, file redirection, and more.

SynnixOS Epic Hobby OS targeting x86_64 CPUs, it includes some hacked together functionality for most essential OSs although, with interactivity via Q

RaidTheWeb 42 Oct 28, 2022
Working example for local_flutter_notification package in Flutter. Includes setting notification at custom time, daily, weekly.

local_notification_example Working example for local_flutter_notification package in Flutter. Includes setting notification at custom time, daily, wee

Nivedita Datta 4 Oct 3, 2021
A Flutter package that two widgets switch with clipper.

flutter_switch_clipper A Flutter package that two widgets switch with clipper. 1.使用 SwitchCipper( initSelect: true, child: const Icon(Icons.fa

FlutterCandies 22 Nov 18, 2022