From 10baca519a6899a2c4c902182cf9bd9cde46135d Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Wed, 18 Mar 2020 16:38:05 -0700 Subject: [PATCH] Add explicit generics to `Future.sync` calls Work around https://github.com/dart-lang/sdk/issues/41106 --- lib/src/async_memoizer.dart | 2 +- lib/src/cancelable_operation.dart | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/src/async_memoizer.dart b/lib/src/async_memoizer.dart index c05c927..90ccfdb 100644 --- a/lib/src/async_memoizer.dart +++ b/lib/src/async_memoizer.dart @@ -40,7 +40,7 @@ class AsyncMemoizer { /// /// If [runOnce] has already been called, this returns the original result. Future runOnce(FutureOr Function() computation) { - if (!hasRun) _completer.complete(Future.sync(computation)); + if (!hasRun) _completer.complete(Future.sync(computation)); return future; } } diff --git a/lib/src/cancelable_operation.dart b/lib/src/cancelable_operation.dart index 0fc7f5d..4228602 100644 --- a/lib/src/cancelable_operation.dart +++ b/lib/src/cancelable_operation.dart @@ -105,9 +105,9 @@ class CancelableOperation { valueOrCancellation().then((T result) { if (!completer.isCanceled) { if (isCompleted) { - completer.complete(Future.sync(() => onValue(result))); + completer.complete(Future.sync(() => onValue(result))); } else if (onCancel != null) { - completer.complete(Future.sync(onCancel)); + completer.complete(Future.sync(onCancel)); } else { completer._cancel(); } @@ -115,7 +115,7 @@ class CancelableOperation { }, onError: (Object error, StackTrace stackTrace) { if (!completer.isCanceled) { if (onError != null) { - completer.complete(Future.sync(() => onError(error, stackTrace))); + completer.complete(Future.sync(() => onError(error, stackTrace))); } else { completer.completeError(error, stackTrace); }