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

tray_manager This plugin allows Flutter desktop apps to defines system tray. tray_manager Platform Support Quick Start Installation ⚠️ Linux requireme

LeanFlutter 122 Dec 22, 2022
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 81 Dec 21, 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

LeanFlutter 351 Jan 7, 2023
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

null 2k Dec 26, 2022
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

null 2k Dec 26, 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

LeanFlutter 57 Dec 22, 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

LeanFlutter 27 Dec 6, 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

LeanFlutter 30 Dec 21, 2022
Use Dart to call Shell, complete the work of compiling Golang CGO code into a so, dll, a, WASM, and etc.

Use Dart to call Shell, complete the work of compiling Golang CGO code into a so, dll, a, WASM, and etc. And place it in the corresponding source file directory of each Flutter platform.

Dorain Gray 30 Dec 30, 2022
A project that makes use of a Typescript back end and a Flutter web front end to consume the Jira API in order to visualize and interact with issues.

A project that makes use of a Typescript back end and a Flutter web front end to consume the Jira API in order to visualize and interact with issues.

Lucas Coelho 1 Mar 20, 2022
A tool for debugging your Flutter apps.

anyinspect_app A tool for debugging your Flutter apps. Platform Support Linux macOS Windows ➖ ✔️ ➖ Installation Downloads are available on the Release

AnyInspect 40 Nov 11, 2022
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

Bruno D'Luka 1.8k Dec 30, 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

null 1 Oct 24, 2021
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

Shivam Bindal 6 Nov 25, 2021
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.

gskinner team 3.5k Jan 2, 2023
TinyPNG4Flutter - A TinyPNG Compress Image Desktop GUI For Flutter. Support macOS and windows

TinyPNG4Flutter A TinyPNG Compress Image Desktop GUI For Flutter. Support macOS

逸风 20 Dec 8, 2022
Ubuntu Yaru Style - Distinct look and feel of the Ubuntu Desktop

Ubuntu Yaru Style - Distinct look and feel of the Ubuntu Desktop Using Yaru To be able to use this package follow this steps: Installation Make you su

Ubuntu 226 Dec 28, 2022
An open source desktop application for creating set-plans for TV and movie productions

lyghts_desktop An open source (Windows) desktop application for creating set-plans for TV and movie productions. Getting Started This application uses

MindStudio 1 Feb 15, 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

ChunKoo Park 72 Dec 2, 2022