setImage method

Future<void> setImage({
  1. TrayIconImageDelegate? delegate,
  2. Uri? path,
  3. ByteBuffer? pixels,
  4. String? asset,
  5. StockIcon? stockIcon,
  6. WinIcon? winIcon,
})

Sets the image on this icon.

If multiple arguments are passed, they are resolved in this order:

  1. delegate
  2. pixels
  3. path
  4. asset
  5. winIcon

If no argument is passed, the image is removed.

For pixels, you should note that {@macro betrayal.image.pixels}

For more information on the parameters, check out TrayIconImageDelegate.

Implementation

Future<void> setImage({
  TrayIconImageDelegate? delegate,
  Uri? path,
  ByteBuffer? pixels,
  String? asset,
  StockIcon? stockIcon,
  WinIcon? winIcon,
}) async {
  _ensureIsActive();
  await _ensureIsReal();

  if (delegate != null) {
  } else if (pixels != null) {
    delegate = TrayIconImageDelegate.fromBytes(pixels);
  } else if (asset != null) {
    delegate = TrayIconImageDelegate.fromAsset(asset);
  } else if (path != null) {
    delegate = TrayIconImageDelegate.fromPath(uri: path);
  } else if (stockIcon != null) {
    delegate = TrayIconImageDelegate.fromStockIcon(stockIcon);
  } else if (winIcon != null) {
    delegate = TrayIconImageDelegate.fromWinIcon(winIcon);
  } else {
    delegate = TrayIconImageDelegate.noImage();
  }
  await delegate.setIcon(_id, _plugin);
}