Skip to content
This repository was archived by the owner on Oct 17, 2024. It is now read-only.

Commit 335a164

Browse files
authored
Add explicit generics to Future.sync calls (#110)
Work around dart-lang/sdk#41106
1 parent 7b9bcd6 commit 335a164

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

lib/src/async_memoizer.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class AsyncMemoizer<T> {
4040
///
4141
/// If [runOnce] has already been called, this returns the original result.
4242
Future<T> runOnce(FutureOr<T> Function() computation) {
43-
if (!hasRun) _completer.complete(Future.sync(computation));
43+
if (!hasRun) _completer.complete(Future<T>.sync(computation));
4444
return future;
4545
}
4646
}

lib/src/cancelable_operation.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,17 +105,17 @@ class CancelableOperation<T> {
105105
valueOrCancellation().then((T result) {
106106
if (!completer.isCanceled) {
107107
if (isCompleted) {
108-
completer.complete(Future.sync(() => onValue(result)));
108+
completer.complete(Future<R>.sync(() => onValue(result)));
109109
} else if (onCancel != null) {
110-
completer.complete(Future.sync(onCancel));
110+
completer.complete(Future<R>.sync(onCancel));
111111
} else {
112112
completer._cancel();
113113
}
114114
}
115115
}, onError: (Object error, StackTrace stackTrace) {
116116
if (!completer.isCanceled) {
117117
if (onError != null) {
118-
completer.complete(Future.sync(() => onError(error, stackTrace)));
118+
completer.complete(Future<R>.sync(() => onError(error, stackTrace)));
119119
} else {
120120
completer.completeError(error, stackTrace);
121121
}

0 commit comments

Comments
 (0)