dispose method Null safety

Future<void> dispose()

Implementation

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

  ReceivePort receivePort = ReceivePort();

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

  _isDisposed = await receivePort.first;

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