dispose method

Future<void> dispose()

Disposes the session and kills the background isolate.

Implementation

Future<void> dispose() async {
  if (_disposed) return;
  _disposed = true;

  _workerPort.send(_DisposeRequest());
  await _responses.firstWhere((msg) => msg is _DisposedResponse);

  _isolate.kill();
}