close method

  1. @override
Future<void> close()
override

Closes the IsolateRunner communication down.

If the isolate isn't running something else to keep it alive, this will also make the isolate shut down.

Can be used to create an isolate, use run to start a service, and then drop the connection and let the service control the isolate's life cycle.

Implementation

@override
Future<void> close() {
  var closeFuture = _closeFuture;
  if (closeFuture != null) return closeFuture;
  var channel = SingleResponseChannel();
  _commandPort.send(list2(_shutdown, channel.port));
  return _closeFuture = channel.result.then(ignore);
}