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
Learn to build apps that work on Android, iOS, Web, and Desktop

Cross-Platform Development with Flutter Course Learn to build apps that work on Android, iOS, Web, and Desktop Go To Course Flutter is Google’s UI too

Mohamed Ibrahim 11 Oct 24, 2022
Actor model implementation in Dart. This package makes it easier to work with isolates, create clusters of isolates.

Actor model implementation in Dart Languages: Introduction About Theater Installing What is Actor Notes about the actors Actor system Actor tree Using

Gleb Batykov 39 Nov 14, 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
An admin panel aplication written with Flutter, aiming work with apps responsiveness.

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

Samilly Nunes 2 Oct 23, 2021
Flutter basic desktop project. Desktop todo app.

Glory Todo Desktop Basic and Primitive Flutter Desktop Project! Goal My goal is to accept my inexperience without worrying about the plugin shortcomin

Özgür 52 Dec 3, 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 346 Jan 3, 2023
A simple easy to use Flutter DApp , which keeps a track of all your day to day transactions by using Ethereum blockchain in the background which in turn increases your credit score.

Sahayog A simple easy to use Flutter DApp , which keeps a track of all your day to day transactions by using Ethereum blockchain in the background whi

Utkarsh Agarwal 15 May 21, 2022
My flutter projects work with JSON

Apps work with JSON A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you star

Samandar 1 Oct 21, 2021
Worney - help people that want to know what time have been made on work time

Worney - help people that want to know what time have been made on work time

Kesse 1 Mar 10, 2022
A cryptocurrency, crypto-currency, or crypto is a digital currency designed to work as a medium of exchange through a computer network that is not reliant on any central authority

A cryptocurrency, crypto-currency, or crypto is a digital currency designed to work as a medium of exchange through a computer network that is not reliant on any central authority, such as a government or bank, to uphold or maintain it.

Prashant Kumar Singh 10 Dec 3, 2022
An intuitive way to work with persistent data in Dart

An intuitive way to work with persistent data in Dart. Full documentation Why Brick? Out-of-the-box offline access to data Handle and hide complex ser

Dutchie 239 Dec 26, 2022
A mobile image uploader in which you can upload image to your personal gallery from either your camera or mobile gallery and it can detect your current geographic location and address using firebase firestore and storage.

Image Uploader In Flutter About It is an Image Uploader gallery which tracks your address from which you're uploading using Flutter and Image picker.

Prahen parija 6 Dec 20, 2022
Scaape, a first-of-its-kind social hangout app that makes organizing group hangouts with people who share similar interests as simple as shooting fish in a barrel.

Inspiration Humans are social beings, hence socializing and meeting new people is an impulsive part of our nature, but due to this recent pandemic whi

Scaape 12 Jan 10, 2022
A Simple Todo app design in Flutter to keep track of your task on daily basis. Its build on BLoC Pattern. You can add a project, labels, and due-date to your task also you can sort your task on the basis of project, label, and dates

WhatTodo Life can feel overwhelming. But it doesn’t have to. A Simple To-do app design in flutter to keep track of your task on daily basis. You can a

Burhanuddin Rashid 1k Jan 6, 2023
Starter architectures for your next Flutter project in order to make it scalable and easy for maintenance and tests.

?? ?? ?? Flutter Starter Architecture (MVVM) My custom starter project for Flutter apps. I was looking for a simple way to build Flutter app in a scal

Junior Medehou 29 Dec 25, 2022
A Flutter plugin for handling Connectivity and REAL Connection state in the mobile, web and desktop platforms. Supports iOS, Android, Web, Windows, Linux and macOS.

cross_connectivity A Flutter plugin for handling Connectivity and REAL Connection state in the mobile, web and desktop platforms. Supports iOS, Androi

MarchDev Toolkit 29 Nov 15, 2022
Easily scan your documents on the go with Paper. Scan those documents at ease with real-time document detection, multi paged pdfs, optimized and cleaner clicks from an easy to navigate UX

Easily scan your documents on the go with Paper. Scan those documents at ease with real-time document detection, multi paged pdfs, optimized and cleaner clicks from an easy to navigate UX

Harsh Joshi 38 Dec 16, 2022
Latest and easy-to-read news, all in your pocket 📱

Observer-flutter About Flutter app for getting live news in different categories Tools used Inshorts News API v2 This API's documentation Get the App

null 3 Jul 13, 2022
A Music Recommendation System made using Flutter and backed by FastAPI.

ProjectX Music A Music Recommendation System made using Flutter and backed by FastAPI. Introduction ProjectX Music is an online mobile application tha

ProjectX Music App 11 Dec 27, 2022