interrupt method

void interrupt([
  1. R? result
])

If the channel hasn't completed yet, interrupt it and complete the result.

If the channel hasn't received a value yet, or timed out, it is stopped (like by a timeout) and the SingleResponseChannel.result is completed with result. If the result type is not nullable, the result must not be null.

Implementation

void interrupt([R? result]) {
  if (result is! R) {
    throw ArgumentError.value(null, "result",
        "The value is needed and the result must not be null");
  }
  _receivePort.close();
  _cancelTimer();
  if (!_completer.isCompleted) {
    // Not in event tail position, so complete the sync completer later.
    _completer.complete(Future.microtask(() => result));
  }
}