dispose method

Future<void> dispose()

Disposes the icon.

This will permanently remove the icon from the system tray. Resources in native code will be released and this instance will become unusable.

Calling this method twice is a no-op.

Implementation

Future<void> dispose() async {
  _logger.finer("trying to dispose");
  if (!_isActive) return;
  _isActive = false;
  if (_isReal) {
    await _plugin.disposeTray(_id);
  }
  _allIcons.remove(_id);

  _disposedAt = StackTrace.current;
  _logger.fine("disposed", null, _disposedAt);
}