tray_manager

pub version

This plugin allows Flutter desktop apps to defines system tray.

Discord


Platform Support

LinuxmacOSWindows
✔️✔️✔️

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

MethodDescriptionLinuxmacOSWindows
destroyDestroys the tray icon immediately.✔️✔️✔️
setIconSets the image associated with this tray icon.✔️✔️✔️
setToolTip-✔️
setContextMenu-✔️✔️✔️
popUpContextMenuPops 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.✔️✔️
getBoundsReturns Rect The bounds of this tray icon.✔️✔️✔️

License

MIT License

Copyright (c) 2021 LiJianying <lijy91@foxmail.com>

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.

Libraries

tray_manager