whenCompleteOrCancel method

void whenCompleteOrCancel(
  1. VoidCallback callback
)

Calls callback either when this future resolves or when the ticker is canceled.

Calling this method registers an exception handler for the orCancel future, so even if the orCancel property is accessed, canceling the ticker will not cause an uncaught exception in the current zone.

Implementation

void whenCompleteOrCancel(VoidCallback callback) {
  void thunk(dynamic value) {
    callback();
  }
  orCancel.then<void>(thunk, onError: thunk);
}