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

Commit

Permalink
Add explicit generics to Future.sync calls (#110)
Browse files Browse the repository at this point in the history
  • Loading branch information
natebosch authored Mar 18, 2020
1 parent 7b9bcd6 commit 335a164
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/src/async_memoizer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class AsyncMemoizer<T> {
///
/// If [runOnce] has already been called, this returns the original result.
Future<T> runOnce(FutureOr<T> Function() computation) {
if (!hasRun) _completer.complete(Future.sync(computation));
if (!hasRun) _completer.complete(Future<T>.sync(computation));
return future;
}
}
6 changes: 3 additions & 3 deletions lib/src/cancelable_operation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -105,17 +105,17 @@ class CancelableOperation<T> {
valueOrCancellation().then((T result) {
if (!completer.isCanceled) {
if (isCompleted) {
completer.complete(Future.sync(() => onValue(result)));
completer.complete(Future<R>.sync(() => onValue(result)));
} else if (onCancel != null) {
completer.complete(Future.sync(onCancel));
completer.complete(Future<R>.sync(onCancel));
} else {
completer._cancel();
}
}
}, onError: (Object error, StackTrace stackTrace) {
if (!completer.isCanceled) {
if (onError != null) {
completer.complete(Future.sync(() => onError(error, stackTrace)));
completer.complete(Future<R>.sync(() => onError(error, stackTrace)));
} else {
completer.completeError(error, stackTrace);
}
Expand Down

0 comments on commit 335a164

Please sign in to comment.