flutter_systray

Last updated:

0 purchases

flutter_systray Image
flutter_systray Images
Add to Cart

Description:

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"
copied to clipboard
Then add the following option to your go-flutter application options:
flutter.AddPlugin(&flutter_systray.FlutterSystrayPlugin{})
copied to clipboard
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),
]);
});
copied to clipboard
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)
]);
copied to clipboard
We can also register callback handlers for events triggered by systray:
FlutterSystray systemTray = FlutterSystray.init();
systemTray.registerEventHandler("counterEvent", () {
setState(() {
_counter += 1;
});
});
copied to clipboard
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
}
copied to clipboard

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.