close method

Future<void> close()

Shuts down the isolate.

Implementation

Future<void> close() async {
  if (_isClosed) return;
  _isClosed = true;

  final (toChild, fromChild, inflight) = await _connected;

  // Fail any outstanding requests.
  for (final c in inflight.values) {
    if (!c.isCompleted) {
      c.completeError(StateError('$runtimeType is closed'));
    }
  }
  inflight.clear();

  toChild.send(null);
  fromChild.close();
}