cancel method

void cancel()

Cancel the listener.

This will also call the onCancel callback, which by default will be remove the listener from the emitter.

Implementation

void cancel() {
  if (!canceled) {
    _canceled = true;
    onCancel?.call();
  }
}