abort method

Future<void> abort([
  1. String? reason
])

Aborts the stream, signaling that the producer can no longer successfully write to the stream and it is to be immediately moved to an error state, with any queued writes discarded.

reason: a string providing a human-readable reason for the abort.

Throws an Error when the stream you are trying to abort is locked.

Implementation

Future<void> abort([String? reason]) {
  try {
    final options = (reason == null) ? [] : [reason];

    return promiseToFuture(callMethod(this, "abort", options));
  } catch (error) {
    throw Error();
  }
}