dispose method Null safety

Future<void> dispose()

Implementation

Future<void> dispose() async {
  if (_isDisposed) {
    return;
  }

  ReceivePort receivePort = ReceivePort();

  _sendPort.send({
    "event": _VideoWorkerEvents.CLEAR,
    "sendPort": receivePort.sendPort,
  });

  dynamic isolateResult = await receivePort.first;
  _isDisposed = true;

  _checkException(isolateResult, isolate: _isolate);

  _isolate.kill(priority: Isolate.immediate);
}