flutter_systray 0.3.2
flutter_systray: ^0.3.2 copied to clipboard

A new flutter plugin project.

flutter_systray #

Flutter Systray is a plugin for go-flutter-desktop that enables support for systray menu for desktop flutter apps.

Supports MacOS, Windows and Linux platforms via trayhost

This plugin implements limited support. There are no submenus, checkboxes and such. PRs are welcome.

Don't forget to check the example app!

Getting Started #

Install the plugin as is customary.

Import as:

import "github.com/JanezStupar/flutter_systray"

Then add the following option to your go-flutter application options:



Below we initialize the systray menu and give it a focus action that bring the flutter app window to front.

MainEntry main = MainEntry(
  title: "title",
  iconPath: path,

FlutterSystray.initSystray(main).then((result) {
          name: "focus",
          label: "Focus",
          tooltip: "Bring application window into focus",
          iconPath: '',
          actionType: ActionType.Focus),

MainEntry - represents the root node of the systray menu. It can have an icon (Win, Linux, Mac) or/and a title and tooltip (Mac). []SystrayAction - a list of systray menu actions. Actions can have an icon, title and tooltip. Name serves as unique identifier.

To change the actions we can call updateMenu function, note that updateMenu will replace existing menu items:

    name: "counterEvent",
    label: "Counter event",
    tooltip: "Will notify the flutter app!",
    iconPath: '',
    actionType: ActionType.SystrayEvent),
    name: "systrayEvent2",
    label: "Event 2",
    tooltip: "Will notify the flutter app!",
    iconPath: '',
    actionType: ActionType.SystrayEvent),
    name: "quit", label: "Quit", tooltip: "Close the application", iconPath: '', actionType: ActionType.Quit)

We can also register callback handlers for events triggered by systray:

FlutterSystray systemTray = FlutterSystray.init();
systemTray.registerEventHandler("counterEvent", () {
  setState(() {
    _counter += 1;

Flutter Systray matches callbacks by SystrayAction.name property.

Available SystrayActions #

At the moment Flutter Systray supports three kinds of actions, which allow you to call platform operation and trigger custom events in your flutter app:

enum ActionType {
  Quit, // Action will trigger application shutdown
  Focus, // Action will trigger GLFW `window.Show` and bring flutter app to front
  SystrayEvent // Action will trigger an event that will call a registered callback in flutter app