TrayIconWidget constructor
TrayIconWidget({
- Key? key,
- required Widget child,
- bool? visible = true,
- bool addToContext = true,
- String? tooltip,
- EventCallback? onTap,
- EventCallback? onSecondaryTap,
- EventCallback? onTapDown,
- EventCallback? onSecondaryTapDown,
- EventCallback? onTertiaryTapDown,
- EventCallback? onTapUp,
- EventCallback? onSecondaryTapUp,
- EventCallback? onTertiaryTapUp,
- EventCallback? onDoubleTap,
- EventCallback? onSecondaryDoubleTap,
- EventCallback? onTertiaryDoubleTap,
- EventCallback? onPointerMove,
- TrayIconImageDelegate? imageDelegate,
- ByteBuffer? imagePixels,
- String? imageAsset,
- Uri? imagePath,
- StockIcon? stockIcon,
- WinIcon? winIcon,
Manages a TrayIcon as a StatefulWidget.
The underlying resource will automatically be disposed according to the lifecycle of the StatefulWidget.
Rebuilding this TrayIconWidget will different parameters will update the icon.
Contrary to TrayIcon.setImage, if tooltip or any of the image related fields
are null
, the current values are kept. This is to ensure that rebuilds
don't interfere with using the TrayIcon widget directly through.
TrayIcon.of(BuildContext context).
For pixels
, you should note that
{@macro betrayal.image.pixels}
For more information on the parameters, check out TrayIconImageDelegate.
Implementation
TrayIconWidget(
{Key? key,
required this.child,
this.visible = true,
this.addToContext = true,
this.tooltip,
EventCallback onTap,
EventCallback onSecondaryTap,
EventCallback onTapDown,
EventCallback onSecondaryTapDown,
EventCallback onTertiaryTapDown,
EventCallback onTapUp,
EventCallback onSecondaryTapUp,
EventCallback onTertiaryTapUp,
EventCallback onDoubleTap,
EventCallback onSecondaryDoubleTap,
EventCallback onTertiaryDoubleTap,
EventCallback onPointerMove,
TrayIconImageDelegate? imageDelegate,
ByteBuffer? imagePixels,
String? imageAsset,
Uri? imagePath,
StockIcon? stockIcon,
WinIcon? winIcon})
: super(key: key) {
if (imageDelegate != null) {
_delegate = imageDelegate;
} else if (imagePixels != null) {
_delegate = TrayIconImageDelegate.fromBytes(imagePixels);
} else if (imageAsset != null) {
_delegate = TrayIconImageDelegate.fromAsset(imageAsset);
} else if (imagePath != null) {
_delegate = TrayIconImageDelegate.fromPath(uri: imagePath);
} else if (stockIcon != null) {
_delegate = TrayIconImageDelegate.fromStockIcon(stockIcon);
} else if (winIcon != null) {
_delegate = TrayIconImageDelegate.fromWinIcon(winIcon);
} else {
_delegate = null;
}
_callbacks = {
WinEvent.select: onTap,
WinEvent.leftButtonDoubleClick: onDoubleTap,
WinEvent.leftButtonDown: onTapDown,
WinEvent.leftButtonUp: onTapUp,
WinEvent.contextMenu: onSecondaryTap,
WinEvent.rightButtonDown: onSecondaryTapDown,
WinEvent.rightButtonUp: onSecondaryTapUp,
WinEvent.rightButtonDoubleClick: onSecondaryDoubleTap,
WinEvent.middleButtonDown: onTertiaryTapDown,
WinEvent.middleButtonUp: onTertiaryTapUp,
WinEvent.middleButtonDoubleClick: onTertiaryDoubleTap,
WinEvent.mouseMove: onPointerMove,
};
}