dispose method

void dispose()

Shuts down the worker isolate and releases resources.

Sends shutdown to the worker, kills the isolate, and closes the receive port. Call when the async connection is no longer needed. After dispose, isInitialized is false and initialize can be called again.

Implementation

void dispose() {
  _workerSendPort?.send('shutdown');
  _workerIsolate?.kill();
  _receivePort?.close();
  _workerSendPort = null;
  _workerIsolate = null;
  _receivePort = null;
  _isInitialized = false;
}