TrayIcon constructor

TrayIcon({
  1. Id? id,
})

Creates a new TrayIcon that controls a single icon in the system tray.

If provided, id has to be between 0 and 4096.

Implementation

TrayIcon({Id? id}) : _id = id ?? _newId() {
  if (_id < 0 || _id >= (_kMaximumId - _kMinimumId)) {
    throw ArgumentError.value(id, "id",
        "The Id needs to be in between 0 and ${_kMaximumId - _kMinimumId}");
  }
  _logger = Logger("betrayal.icon.${_id.hex}");
  _allIcons[_id] = this;
  _isActive = true;
  _logger.fine("initialized instance");
  // In Debug mode users can hot restart the app.
  // [As of right now, there is no way to detect that.](https://github.com/flutter/flutter/issues/10437)
  // That means we have to call an init method for cleanup.
  // This method is automatically called, when the [BetrayalPlugin._instance]
  // is constructed.
  // This happens happens the first time [_plugin] is accessed.
  if (kDebugMode) _plugin._noop();
}