dispose method
Releases the Dart isolate after the task's close command has completed.
Implementation
Future<void> dispose() async {
if (_disposed) return;
if (_pending.isNotEmpty) {
throw StateError('Cannot dispose a native task worker with pending requests.');
}
_disposed = true;
await _releaseResources(kill: true);
}