systray 0.5.4 copy "systray: ^0.5.4" to clipboard
systray: ^0.5.4 copied to clipboard

outdated

Forked Null Safe version of flutter_systray

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!

This plugin has been forked from Janez Štupar

Getting Started #

Install the plugin as is customary.

Import as:

import "github.com/sonr-io/systray"

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

flutter.AddPlugin(&systray.SystrayPlugin{})

API #

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,
);

Systray.initSystray(main).then((result) {
    Systray.updateMenu([
      SystrayAction(
          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:

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

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

Systray 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
}
5
likes
110
pub points
24%
popularity

Publisher

verified publishersonr.io

Forked Null Safe version of flutter_systray

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on systray