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

outdated

Forked Null Safe version of flutter_systray

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:

flutter.AddPlugin(&flutter_systray.FlutterSystrayPlugin{})

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

FlutterSystray.initSystray(main).then((result) {
    FlutterSystray.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:

FlutterSystray.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:

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
}
5
likes
0
pub points
37%
popularity

Publisher

verified publishersonr.io

Forked Null Safe version of flutter_systray

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on systray