• Stars
    star
    223
  • Rank 177,572 (Top 4 %)
  • Language
    C++
  • License
    MIT License
  • Created about 3 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

This plugin allows Flutter desktop apps to defines system tray.

tray_manager

pub version

This plugin allows Flutter desktop apps to defines system tray.


English | 简体中文


Platform Support

Linux macOS Windows
✔️ ✔️ ✔️

Screenshots

macOS Linux Windows
image

Quick Start

Installation

Add this to your package's pubspec.yaml file:

dependencies:
  tray_manager: ^0.2.0

Or

dependencies:
  tray_manager:
    git:
      url: https://github.com/leanflutter/tray_manager.git
      ref: main

Linux requirements

  • ayatana-appindicator3-0.1 or appindicator3-0.1

Run the following command

sudo apt-get install libayatana-appindicator3-dev

Or

sudo apt-get install appindicator3-0.1 libappindicator3-dev

Usage

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

await trayManager.setIcon(
  Platform.isWindows
    ? 'images/tray_icon.ico'
    : 'images/tray_icon.png',
);
Menu menu = Menu(
  items: [
    MenuItem(
      key: 'show_window',
      label: 'Show Window',
    ),
    MenuItem.separator(),
    MenuItem(
      key: 'exit_app',
      label: 'Exit App',
    ),
  ],
);
await trayManager.setContextMenu(menu);

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.addListener(this);
    super.initState();
    _init();
  }

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

  void _init() {
    // ...
  }

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

  @override
  void onTrayIconMouseDown() {
    // do something, for example pop up the menu
    trayManager.popUpContextMenu();
  }

  @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
    }
  }
}

Who's using it?

API

TrayManager

Method Description Linux macOS Windows
destroy Destroys the tray icon immediately. ✔️ ✔️ ✔️
setIcon Sets the image associated with this tray icon. ✔️ ✔️ ✔️
setIconPosition Sets the icon position of the tray icon. ✔️
setToolTip Sets the hover text for this tray icon. ✔️ ✔️
setContextMenu Sets the context menu for this icon. ✔️ ✔️ ✔️
popUpContextMenu Pops up the context menu of the tray icon. ✔️ ✔️
getBounds Returns Rect The bounds of this tray icon. ✔️ ✔️

License

MIT

More Repositories

1

awesome-flutter-desktop

A curated list of awesome things related to Flutter desktop.
1,509
star
2

flutter_distributor

An all-in-one Flutter application packaging and distribution tool, providing you with a one-stop solution to meet various distribution needs.
Dart
781
star
3

window_manager

This plugin allows Flutter desktop apps to resizing and repositioning the window.
C++
678
star
4

widget-livebook

Live preview example for flutter widgets.
Dart
611
star
5

flutter_flipperkit

Flipper (Extensible mobile app debugger) for flutter.
Java
359
star
6

auto_updater

This plugin allows Flutter desktop apps to automatically update themselves (based on sparkle and winsparkle).
C++
274
star
7

hotkey_manager

This plugin allows Flutter desktop apps to defines system/inapp wide hotkey (i.e. shortcut).
Dart
131
star
8

.github

96
star
9

launch_at_startup

This plugin allows Flutter desktop apps to Auto launch on startup / login.
C++
87
star
10

screen_capturer

This plugin allows Flutter desktop apps to capture screenshots.
C++
80
star
11

protocol_handler

This plugin allows Flutter apps to register and handle custom protocols (i.e. deep linking).
C++
75
star
12

contextual_menu

This plugin allows Flutter desktop apps to create native context menus.
C++
74
star
13

local_notifier

This plugin allows Flutter desktop apps to notify local notifications.
C++
69
star
14

screen_text_extractor

This plugin allows Flutter desktop apps to extract text from screen.
C++
52
star
15

clipboard_watcher

This plugin allows Flutter apps to watch clipboard changes.
C++
50
star
16

screen_retriever

This plugin allows Flutter desktop apps to Retrieve information about screen size, displays, cursor position, etc.
C++
45
star
17

flipper-plugin-reduxinspector

Redux Inspector for flipper (Extensible mobile app debugger).
JavaScript
42
star
18

anyinspect_app

AnyInspect desktop app.
Dart
41
star
19

flutter_apps

A collection of apps built on Flutter.
Dart
41
star
20

flutter_flipperkit_plugins

Plugins for flutter flipperkit.
Dart
33
star
21

uni_links_desktop

A desktop (supports macOS and Windows) implementation of uni_links plugin.
C++
28
star
22

keypress_simulator

This plugin allows Flutter desktop apps to simulate key presses.
C++
27
star
23

flutter_tencent_captcha

适用于 Flutter 的腾讯云验证码插件
Java
26
star
24

uni_translate

A universal translate client.
Dart
21
star
25

flutter_aliyun_captcha

适用于 Flutter 的阿里云滑动验证插件
Dart
20
star
26

uni_ocr

A universal ocr client.
Dart
18
star
27

influxui

A fully featured Flutter widgets library, Inspired by mantine.
Dart
16
star
28

flutter_svprogresshud

A clean and lightweight progress HUD for flutter app.
Objective-C
15
star
29

flutter_superplayer

适用于 Flutter 的腾讯云超级播放器插件
Java
14
star
30

shortcut_menu_extender

This plugin allows Flutter apps to Extending global shortcut menus.
C++
12
star
31

makeanyicon

A configurable icon maker.
Dart
11
star
32

vclibs

Let your flutter windows apps include vclibs.
C++
11
star
33

storybook_dart

Storybook for Flutter, build your Flutter widgets storybook using storybookjs.
Dart
11
star
34

anyinspect

AnyInspect is a tool for debugging your Flutter apps.
Dart
10
star
35

flutter_qiyu

适用于 Flutter 的七鱼客服插件
Objective-C
9
star
36

flutter_photo_picker

Photo Picker plugin for Flutter.
Swift
9
star
37

awesome-flutter-mobile

A curated list of awesome things related to Flutter mobile.
9
star
38

flutter_txugcupload

适用于 Flutter 的腾讯云点播上传 SDK
Objective-C
7
star
39

menu_base

Dart
5
star
40

flutter_yunpian_captcha

适用于 Flutter 的云片行为验证插件
Java
5
star
41

sync2gitee

LeanFlutter - To make the flutter even simpler
5
star
42

flipper-plugin-dbbrowser

Database Browser for flipper (Extensible mobile app debugger).
JavaScript
4
star
43

preference_list

Simplifies building preference pages with flexibility and ease-of-use.
Dart
4
star
44

any_icon_maker

A configurable icon maker.
Dart
4
star
45

anyinspect_web

AnyInspect website.
TypeScript
3
star
46

embed_web_pkgs

Dart
3
star
47

anyinspect_plugins

Plugins for AnyInspect
Dart
3
star
48

flutter_flipperkit_examples

Examples for flutter flipperkit.
Dart
3
star
49

flutter_desktop_examples

C++
2
star
50

leanflutter_snippets

Dart
2
star
51

flutter-desktop-plugins

Swift
2
star
52

awesome_list_maker

A awesome list maker
Dart
2
star
53

website

LeanFlutter web site
Astro
2
star
54

flutter_universal_boilerplate

Dart
1
star
55

base_orm

Dart
1
star
56

flutter_distributor_docs_zh

1
star
57

harmonic

Dart
1
star
58

flutter_yidun_captcha

适用于 Flutter 的网易易盾行为式验证码插件
Java
1
star
59

anyinspect_integrate_example

C++
1
star
60

openai-api-bridge

TypeScript
1
star
61

analyzeanyapp

1
star
62

all_sponsors_maker

Dart
1
star
63

mostly_reasonable_lints

A mostly reasonable set of lints for Dart and Flutter projects.
Dart
1
star