listenCancelForAsyncTask<T> method Null safety

Future<T> listenCancelForAsyncTask<T>(
  1. CancelToken? cancelToken,
  2. Future<T> future
)

Implementation

static Future<T> listenCancelForAsyncTask<T>(
    CancelToken? cancelToken, Future<T> future) {
  return Future.any([
    if (cancelToken != null) cancelToken.whenCancel.then((e) => throw e),
    future,
  ]);
}