cancel method Null safety

void cancel()

Removes the handler that you installed with listen It's save to call cancel on an already canceled subscription

Implementation

void cancel() {
  if (!canceled) {
    endOfPipe.removeListener(handler);
    canceled = true;
  }
}